CSS Flashcards
What are the names of individual pieces of a CSS rule?
selector, curly brackets, property, value
In CSS, how do you select elements by their class attribute?
.class
In CSS, how do you select elements by their type?
element {}
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.
hex, rgb, color name(keyword)
bonus points rgba, hsl, hsla
What CSS properties make up the box model?
border, margin, padding
Which CSS property pushes boes away from each other?
margin
Which CSS property adds space between a box’s content and its border?
padding
What is a pseudo-class?
keyword that specifies a special state of the selected element
eg: button:hover{}
What are CSS pseudo-classes useful for?
lets you apply styling to elements in relation to external factors
Name at least two units of type size in CSS
px, em, rem, pt
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 (left to right)
What is the default flex-wrap of a flex container?
no wrap (everything on one line)
Why do two div elements “vertically stack” on one another by default?
div elements are block elements
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?
static
How does setting position: relative on an element affect document flow?
allows us to move the element relative to where it should be
does not change document flow - purely visual
How does setting position: relative on an element affect where it appears on the page?
with no other augments - it would be the same
needs top, bottom, left, right to modify
How does setting position: absolute on an element affect document flow?
it is removed from the normal flow - doesn’t affect position of surroundings (used to place elements on top of other elements)
How does setting position: absolute on an element affect where it appears on the page?
positions relative to the boundary of the previous parent non-statically positioned element
How do you constrain an absolutely positioned element to a containing block?
set the containing block to be a non static element (usually position: relative)
What are the four box offset properties?
top, bottom, left, right
What are the four components of “the Cascade”.
source order, inheritance, specificity, important rule
What does the term “source order” mean with respect to CSS?
styling lower in the style sheet takes priority
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
inheritance rule
List the three selector types in order of increasing specificity.
element/type > class > id
Why is using !important considered bad practice?
overrides cascade