CSS Flashcards
What are the names of the individual pieces of a CSS rule?
the selector, the declaration of the code block, and then the properties and its values.
In CSS, how do you select elements by their class attribute?
.class-name
In CSS, how do you select elements by their type?
just write their name so ex: h1, body, etc.
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.
You can use color (name of color), the function rgb (numbers), and hex codes(#).
*HSL, HSLA and RGBA are other ways.
What CSS properties make up the box model?
Height, width, padding, border, and margin
Which CSS property pushes boxes away from each other?
Margin. It is OUTSIDE the border element
*Margin is wearing a puffy jacket
Which CSS property add space between a box’s content and its border?
Padding. It is INSIDE the border element
*Padding is gaining weight
What is a pseudo-class?
A keyword that specifies a special state of a selected element.
What are CSS pseudo-classes useful for?
They’re useful for applying a style in relation to the user or their cursor.
Name two types of units that can be used to adjust font-size in CSS.
Px, %, rem, and em
TIP: Best to use “em” for device flexibility
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?
flex-direction: row;
What is the default flex-wrap of a flex container?
flex-wrap: nowrap;
Why do two div elements “vertically stack” on one another by default?
They are block level elements, so they take up the full width of the page and push other elements down.
What is the default flex-direction of an element with display: flex?
row (left to right)
What is the default value for the position property of HTML elements?
position: static;
How does setting position: relative on an element affect document flow?
“position: relative” stays the same in document flow, makes the element move in relation to where it would be in normal flow. The position of surrounding elements isn’t affected.
How does setting position: relative on an element affect where it appears on the page?
“position: relative” makes the element move in relation to where it would have been in normal flow. Without offset properties it just stays in the same place.
How does setting position: absolute on an element affect document flow?
It is removed from the document flow. All neighboring elements view it as not existing anymore and they will fill that space up.
How does setting position: absolute on an element affect where it appears on the page?
“position: absolute” makes the element move in relation to its containing element. It is taken out of normal flow.
Cody’s answer:
It gets positioned within the nearest non-static ancestor. Moves that element into a layer of the document for strictly positioned elements. They check for any neighboring elements with their position set to not static.
How do you constrain an absolutely positioned element to a containing block?
Change the element container’s position to not static, usually relative.
What are the four box offset properties?
top, bottom, left, and right
What are the four components of “the Cascade”.
source order, inheritance, specificity, and !important rule?