CSS Flashcards
What are the names of the individual pieces of a CSS rule?
Selector, declaration block, properties, values
In CSS, how do you select elements by their class attribute?
.className
In CSS, how do you select elements by their type?
elementName
In CSS, how do you select an element by its id attribute?
idName, octothorpe
Name different types of values you can use to specify colors in CSS.
Hex, rgb, color name, rgba, (HSL, hsla (not used frequently))
What CSS properties make up the box model?
Border, margin, padding, (content: width and height)
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?
A class that is applied by the browser to an element in a specific circumstance. They can change the appearance of elements when the user interacts with them.
What are CSS pseudo-classes useful for?
Styling elements based on user actions
Name at least two units of type size in CSS.
Percentage, pixels, 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?
Because “div” is a block-level element
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?
It does not affect document flow
How does setting position: relative on an element affect where it appears on the page?
It positions an element relative to where it would normally be in the document flow
How does setting position: absolute on an element affect document flow?
It is removed from the document flow entirely
How does setting position: absolute on an element affect where it appears on the page?
It removes it from the document flow and positions it within the first non-static ancestor
How does setting position: fixed on an element affect both document flow and where it appears on the page?
It removes it from the document flow just like position: absolute. However, it positions the element in relation to the viewport instead of the first non-static ancestor
How do you constrain an absolutely positioned element to a containing block?
Set position: relative; on the containing block
What are the four box offset properties?
Top, right, bottom, left