CSS Flashcards
What are the names of the individual pieces of a CSS rule?
Rule set, selector, declaration/declaration block, property, value.
In CSS, how do you select elements by their class attribute?
With a dot/period ( . )
In CSS, how do you select elements by their tag name?
With the tag/element name.
In CSS, how do you select an element by its id attribute?
With the #.
Name three different types of values you can use to specify colors in CSS.
Hexidecimal, rgba, hsla.
What CSS properties make up the box model?
Height, width, padding, border, margin.
Which CSS property pushes boxes away from each other?
Margin.
Which CSS property adds space between a box’s content and its border?
Padding.
What is a pseudo-class?
A keyword added to a selector that specifies a special state of the selected element(s).
What are CSS pseudo-classes useful for?
Giving additional information, additional functionality, and applying styles.
Name two types of units that can be used to adjust font-size in CSS.
Pixels, 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?
Default flex-direction is row.
What is the default flex-wrap of a flex container?
Default flex-wrap is nowrap.
What does justify content do?
This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow the line.
What does align-items do?
This defines the default behavior for how flex items are laid out along the cross axis on the current line. Think of it as the justify-content version for the cross-axis (perpendicular to the main-axis).
Why do two div elements “vertically stack” on one another by default?
They are block-level elements.
What is the default flex-direction of an element with display: flex?
Row.
What are the three primary components of a page layout? (Which helper classes do you need?)
Container class/element, row class/element, column class/element.
What is the minimum number of columns that you should put in a row?
One.
What is the purpose of a container?
To hold the row class/element, and the column class/element. (Also to provide additional styling/functionality).
What is the default value for the position property of HTML elements?
Default position property is Static.
How does setting position: relative on an element affect document flow?
Relative position moves an element in relation to where it would have been in normal flow. (Document flow is unaffected).
How does setting position: relative on an element affect where it appears on the page?
Position: relative will have no affect until a box offset property is set. It will then move relative to where it would have been in normal flow.
How doe setting position: absolute on an element affect document flow?
The box (element) is taken out of normal flow and no longer affects the position of other elements on the page. (They act like it is not there.)
How does setting position: absolute on an element affect where it appears on the page?
The element is taken out of normal flow, then the box offset properties can specify where the element should appear in relation to its containing element.
(Taken out of normal flow “above” other elements,
in relation to closest non-static ancestor.)
What are the four box offset properties?
Top, bottom, left, right.
How do you constrain an absolutely positioned element to a containing block?
Assign anything expect position static to the containing block.
What are the four components of “the Cascade”.
- Inheritance.
- Specificity.
-Source-order. - !important (rule).
What does the term “source order” mean with respect to CSS?
- The priority/strength is given to rules lower down the style sheet.
How is it possible for they styles of an element to be applied to its children as well without an additional CSS rule?
- Font and text are inherited properites.
List the three selector types in order of increasing specificity.
- Element.
- Class.
- ID.
Why is using !important considered bad practice?
- Has extremely high specificity so it is very hard to override.
Bonus: (Two main reasons why it exists):
- Working inside a premade template that has a style that needs to be over ridden. (Like wordpress).
- If you are making a CSS library.