CSS Flashcards
Describe the syntax of a CSS rule-set.
A typical CSS rule-set consists of one of more selectors which identifies the HTML elements to be styled, and the declaration block within curly braces, which contains the CSS property name(s) and property value(s), separated by a colon and completed with a semicolon. If there there are multiple property-value sets, they should be separated by semicolons.
In CSS, how do you select elements by their class attribute?
.class-name
In CSS, how do you select elements by their type?
Using just the element name, ex: h1, p, div
In CSS, how do you select an element by its id attribute?
id-name
Name three different types of values you can use to specify colors in CSS.
RGB Values, Hex Codes, and color names. -extra- HSL HSLA RGBA
What CSS properties make up the box model?
The content width and height, padding, border, margin.
Which CSS property pushes boxes away from each other?
Margins.
Note: Be aware of margin collapse where the top and bottom margins of elements can collapse into a single margin that is equal to the largest value of the two margins.
Which CSS property adds space between a box’s content and its border?
Padding
What is a pseudo-class?
It’s a keyword added to a selector that specifies a special state of the selected element(s)
What are CSS pseudo-classes useful for?
CSS pseudo-classes are used to add styles to selectors when those selectors meet certain conditions, whether that’s based on the content of the document tree, or on external factors, ex: position of the mouse (hover)
Name at least two units of type size in CSS.
Px and percentages
-extra-
ems, ex, and rem
What CSS property controls the font used for the text inside an element?
Font-family
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
What is the default flex-direction of an element with display: flex?
Row
What is the default value for the position property of HTML elements?
position: static
How does setting position: relative on an element affect document flow?
It does not affect the position of surrounding elements; they stay
in the position they would be in in normal flow. The elements just moves.
How does setting position: relative on an element affect where it appears on the page?
Relative positioning moves an element in relation to where it would have been in normal flow, based on the box offset property values.
How does setting position: absolute on an element affect document flow?
It is taken out of normal flow, it does not affect the position of any surrounding elements, it’s like it’s not there.
How does setting position: absolute on an element affect where it appears on the page?
Absolutely positioned elements move as users scroll up and
down the page. It will position itself in relation to the nearest ancestor container it’s in that has a non-static position property.
How do you constrain an absolutely positioned element to a containing block?
They constrain themselves to the first non-static containing block, so it must be set to a position property that is relative or it will go up the chain of parents that have a non-static property on it.
What are the four box offset properties?
Top, bottom, left, right.
What are the four components of “the Cascade”.
Source order, Inheritance, specificity, and important keyword
What does the term “source order” mean with respect to CSS?
The order that your CSS rules are written in your stylesheet.