CSS Flashcards
What are the names of the individual pieces of a CSS rule?
Selector { declaration (declaration has a property: value pair) }
In CSS, how do you select elements by their class attribute?
Use .classname
In CSS, how do you select elements by their tag name?
Write the list of tags you want to target separated by commas.
In CSS, how do you select an element by its id attribute?
idname
Name three different types of values you can use to specify colors in CSS.
Keywords, RGB Values (either as CSV or hexadecimal), and HSL (height, saturation, lightness)
What CSS properties make up the box model?
Margin, border, padding, content
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 box-sizing “border-box”?
This prevents the box from stretching beyond the size you want — instead shrinks content
True or False: Padding and margin are the preferred way to center content on the page.
False — they should only be used for small moves! (Like giving text in an input box space)
What is a pseudo-class?
Add style to selectors that only activate under certain conditions to change state or position
What are CSS pseudo-classes useful for?
Increasing usability of your webpage
Name two types of units that can be used to adjust font-size in CSS.
Px, em, rem, %
What CSS property controls the font used for the text inside an element?
Font-family
What is the different between rem and em?
rem is based on the root document size (1rem = 16px) but ‘em checks most direct parent
What is the default flex-direction of a flex container?
row — justify content works on the horizontal axis
What is the default flex-wrap of a flex container?
Nowrap
• Justify content works on the _______ axis, and align items works on the __________ axis.
Primary, secondary.
Why do two div elements “vertically stack” on one another by default?
Div elements are block elements by default
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?
The order that rulesets appear in the style sheet
How is it possible for the styles of an element to be applied to its children as well without additional CSS rules?
Inheritance!
List the three selector types in order of increasing specificity.
Type, class, id
Why is using !important considered bad practice?
Typically you can achieve what you’re trying to do through source order
What does the transform property do?
Lets you visually change the alignment of an element.
Give four examples of CSS transform functions.
Translate, scale, rotate, skew
Give two examples of media features that you can query in an @media rule.
Max/min width, orientation, pixel-sizes, …
Which HTML tag is used in mobile-responsive web pages?
The meta tag with name=viewport
The transition property is shorthand for what 4 properties?
transition-property, transition-duration, transition-timing-function, & transition-delay
What is a breakpoint in reponsive web design?
Widths that cause content to “break” in some way — like being far too long or too squished
What is the advantage of using a percentage (e.g. 50%) width instead of a fixed (e.g. px) width for a “column” class in a responsive layout?
Percentages will scale with the screen as it changes, pixels won’t
If you introduce CSS rules for a smaller min-width after the styles for a larger min-width in your style sheet, the CSS rules for the smaller min-width will “win” Why is that?
CSS rules are applied in order from top to bottom of the code!