CSS Flashcards
Selectors
indicate which element the rule applies to. The same rule can apply to more than one element if you separate the element names with commas.
Declarations
Declarations indicate how
the elements referred to in the selector should be styled. Declarations are split into two parts (a property and a value), and are separated by a colon.
Link
link href=”css/example.css” type=”text/css”
rel=”stylesheet” />
unIverSaL SeLector
Applies to all elements in the document
* {}
Targets all elements on the page
type SeLector
h1, h2, h3 {}
Targets the <h1>, </h1><h2> and </h2><h3> elements</h3>
Class Selector
.note {} Targets any element whose class attribute has a value of note p.note {} Targets only <p> elements whose class attribute has a value of note</p>
Class Selector
.note {} Targets any element whose class attribute has a value of note p.note {} Targets only <p> elements whose class attribute has a value of note</p>
ID selector
#introduction {} Targets the element whose id attribute has a value of introduction
child selector
li>a {}
Targets any <a> elements that are children of an </a><li><a> element (but not other </a><a> elements in the page)</a></li>
deScendant SeLector
p a {}
Targets any <a> elements that sit inside a <p> element, even if there are other elements nested between them</p></a>
adjacent SIBLIng SeLector
h1+p {}
Targets the first <p> element after any </p><h1> element (but not other </h1><p> elements)
</p>
generaL SIBLIng SeLector
h1~p {}
If you had two <p> elements that are siblings of an </p><h1> element, this rule would apply to both</h1>
• What are the names of the individual pieces of a CSS rule?
group of selectors -> declaration block
• In CSS, how do you select elements by their class attribute?
.notation
• In CSS, how do you select elements by their type?
Type Selectors correspond with HTML elements. ID Selectors are used by adding # in front of an elements ID. Class Selectors are used by adding a period in front of an elements class.
• In CSS, how do you select an element by its id attribute?
intro
Property: Value;
The property which is an identifier, that is a human-readable name, that defines which feature is considered.
The value which describe how the feature must be handled by the engine. Each property has a set of valid values, defined by a formal grammar, as well as a semantic meaning, implemented by the browser engine.
CSS rule (rule set)
CSS Summary
block Box model
If a box has an outer display type of block, it will behave in the following ways:
The box will break onto a new line.
The box will extend in the inline direction to fill the space available in its container. In most cases this means that the box will become as wide as its container, filling up 100% of the space available.
The width and height properties are respected.
Padding, margin and border will cause other elements to be pushed away from the box.
Some HTML elements, such as <h1> and </h1><p>, use block as their outer display type by default.</p>
Inline box
If a box has an outer display type of inline, then:
The box will not break onto a new line.
The width and height properties will not apply.
Vertical padding, margins, and borders will apply but will not cause other inline boxes to move away from the box.
Horizontal padding, margins, and borders will apply and will cause other inline boxes to move away from the box.
Some HTML elements, such as <a>, <span>, <em> and <strong> use inline as their outer display type by default.</strong></em></span></a>
What is the default flex-direction of a flex container?
The default flex-direction of a flex container is row,
• What is the default flex-wrap of a flex container?
nowrap (default): all flex items will be on one line
• How does setting position: relative on an element affect document flow?
Normal document flow, if you just put the position relative without any box offset properties
• How does setting position: relative on an element affect where it appears on the page?
It moves from the place where it is normal in document flow
• How does setting position: absolute on an element affect document flow?
Can block out other boxes? Sibling elements will side into place and it doesn’t exist anymore in document flow, its ripped out and you can move it wherever
x, y, z index
x axis, y axis, z-index makes things three dimensional aka what element will be over something else. or like a gray background
• Name three different types of values you can use to specify colors in CSS.
• RGB values, hex codes, color names, HSL, Alpha channel
What are the four components of “the Cascade”.
source order, inheritance, specificity and !important
• What does the term “source order” mean with respect to CSS?
However, it is common in CSS development to declare styling for an element on the same property multiple times throughout your stylesheet. For instance, given the following HTML:
<h1>Some News Headline</h1>
And the following CSS:
.news-headline {
font-size: 60px;
}
.medium-text {
font-size: 25px;
}
Both the news-headline and medium-text classes include a font-size property. So which style ultimately gets applied?
The last element