CSS Flashcards
What are the names of the individual pieces of a CSS rule?
○ ruleset: css selector, declaration block, declaration, property, and value
In CSS, how do you select elements by their class attribute?
○ .classname (with a dot)
In CSS, how do you select elements by their type?
○ typename (nothing additional)
In CSS, how do you select an element by its id attribute?
○ #idname (with a #)
Name three different types of values you can use to specify colors in CSS.
Color Keywords, RGB (Red Green Blue), and HSL (Hue Saturation Light)
What CSS properties make up the box model?
○ Margin -> Border -> Padding -> Content (width + height)
Which CSS property pushes boxes away from each other?
Margin (takes the higher margin value)
Which CSS property add space between a box’s content and its border?
Padding
What is a pseudo-class?
An implied class based off of a certain element’s state (i.e. hover).
What are CSS pseudo-classes useful for?
Changing styles based on what the user is doing or has done. Selecting a group of elements via a pattern to avoid creating new classes for each.
Name two types of units that can be used to adjust font-size in CSS.
px, pt, em, 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?
○ row
• What is the default flex-wrap of a flex container?
○ nowrap
• 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 is the default value for the position property of HTML elements?
○ static (normal)
• How does setting position: relative on an element affect document flow?
○ it doesn’t
• How does setting position: relative on an element affect where it appears on the page?
○ it doesn’t, with no offsets
• How does setting position: absolute on an element affect document flow?
○ removed from document flow entirely
• How does setting position: absolute on an element affect where it appears on the page?
○ sits in ancestor element’s top-left corner, with no offsets
• How do you constrain an absolutely positioned element to a containing block?
○ setting an ancestor to something non-static
• What are the four box offset properties?
○ top, bottom, left, right (element position has to have non-static value)
• What are the four components of “the Cascade”.
○ Source order, inheritance, specificity, !important
• What does the term “source order” mean with respect to CSS?
○ rulesets will override similar selectors above it
• How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
○ some properties are inherited by default
• List the three selector types in order of increasing specificity.
○ type, class, ID
• Why is using !important considered bad practice
○ it ruins the natural cascade flow
• What does the transform property do?
○ modifies the coordinate space of the CSS
• Give four examples of CSS transform functions.
○ rotate, translate, skew, scale
• The transition property is shorthand for which four CSS properties?
○ transition-property, transition-duration, transition-timing-function, transition-delay
• Give two examples of media features that you can query in an @media rule.
○ min-width, orientation
• Which HTML meta tag is used in mobile-responsive web pages?
○ meta name=”viewport” content=”width=device-width, initial-scale=1”