CSS Flashcards
What are the names of the individual pieces of a CSS rule?
selector {
property: value; /* declaration */
}
In CSS, how do you select elements by their class attribute?
.class
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 three different types of values you can use to specify colors in CSS.
keyword, rgb, hex code
What CSS properties make up the box model?
margin, padding, and border
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 is a pseudo-class?
classes applied when a user is interacting with an element; hover, active, and focus
What are CSS pseudo-classes useful for?
temporarily styling elements depending on the user’s interactions with them
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 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?
divs are block by default, block elements take up as much horizontal space as possible
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
How does setting position: relative on an element affect document flow?
Can be positioned from its default position on the page with top/bottom/left/right properties, other elements maintain their position/flow
How does setting position: relative on an element affect where it appears on the page?
Does not change where it appears by default
How does setting position: absolute on an element affect document flow?
Removes element from flow, positions it in relation to its nearest non-static parent element by default, can be positioned with top/bottom/left/right properties, other elements shift like it’s not there
How does setting position: absolute on an element affect where it appears on the page?
Removes it from the document flow and positions it relative to its parent element
How do you constrain an absolutely positioned element to a containing block?
Container must be positioned (not static)
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
What does the term “source order” mean with respect to CSS?
the order rules are written in your stylesheet. The last styling for an element 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?
certain CSS properties are inherited by children elements (font-family, color), and ‘inherit’ can be used as the value for many properties that aren’t inherited by default
List the three selector types in order of increasing specificity.
- element type and pseudo-elements
- class, attribute, and pseudo-classes
- ID
- and combinators don’t affect specificity
Why is using !important considered bad practice?
it makes debugging more difficult by breaking the natural cascading of the stylesheets
What does the transform property do?
transforms elements (move it)
Give four examples of CSS transform functions.
rotate, scale, skew, translate
What is a breakpoint in responsive Web design?
attribute value (eg max-width: 800px) where screen will adjust depending on size of user’s screen
the point at which a media query is introduced
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?
more adaptable to different screen sizes, elements will resize as the screen does
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?
cascading, later rules in the stylesheet take priority
Give two examples of media features that you can query in an @media rule.
min/max width, min/max height, orientation
Which HTML meta tag is used in mobile-responsive web pages?
viewport