CSS Flashcards
What are the names of the individual pieces of a CSS rule?
selector, declaration block, property, value
In CSS, how do you select elements by their class attribute?
.class-name {
}
In CSS, how do you select elements by their type?
type {
}
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, Hex code, color names
What CSS properties make up the box model?
Border, padding, margin
Which CSS property pushes boxes away from each other?
Margin
Which CSS property add space between a box’s content and its border?
Padding
What are CSS pseudo-classes useful for?
Applying styling based on user actions
What is a pseudo-class?
A class added to a selector to specify a special state for that element.
Name at least two units of type size in CSS.
pixel, rem, em
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?
What is the default flex-direction of an element with display: flex?
row
What is the default flex-wrap of a flex container?
no-wrap
Why do two div elements “vertically stack” on one another by default?
Because divs are block level elements
What are the four components of “the Cascade”.
Source order, Inheritance, Specificity, !important
What does the term “source order” mean with respect to CSS?
The rule that is written last in an external stylesheet is the one that is applied.
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
Inheritance, some properties are inheritable prop, ex: color, font-family
List the three selector types in order of increasing specificity.
Least: Type Selector
Class Selector
Most: ID Selectors
Why is using !important considered bad practice?
It disrupts the natural cascade of CSS.
What does the transform property do?
Allows you to alter how an element appears in its coordinate plane.
Give two examples of media features that you can query in an @media rule.
Width and height
Which HTML meta tag is used in mobile-responsive web pages?
Viewport meta tag - makes the width of the website appear in the actual width of the device screen
What is a breakpoint in responsive Web design?
The point where your content styling would change.
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?
The column will always be half the screen size, adjusting to different screen sizes. If you used hard pixels, would have to change a lot of code.
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?
Because of source order. The later rule will win.