CSS Flashcards
What are the names of the individual pieces of a CSS rule set?
selector {
declaration block
}
within declaration block
properties: values;
In CSS, how do you select elements by their class attribute?
.name of class
In CSS, how do you select elements by their type?
name of type aka element
ex: h1, div
In CSS, how do you select an element by its id attribute?
name of id
Name 3 different types of values you can use to specify colors in CSS
- hex code
- rgb ()
- rgba ()
- hsl
- hsla
What CSS properties make up the box model?
- margin
- border
- padding
- content (width & 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 CSS class that is applied by a browser! It can be added to the selector to apply pre-set behaviors/state to the selected elements. But the developer cannot make it take affect, only the browser can when it’s conditionss are met.
ex) :hover
:visited
:nth-child()
What are CSS pseudo-classes useful for?
It lets us apply style to an element in relation to the user’s activity!
It also help cut down the amount of code.
ex) :hover
:visited
Name 2 types of units that can be used to adjust font-size in CSS
rem
px
em* (grows exponentially if inside a layer)
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?
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 doesn’t.
How does setting position: relative on an element affect where it appears on the page?
It will appear relative to itself in its static state, with the specified values of top, right, bottom, left
How does setting position: absolute on an element affect document flow?
The element is removed from the normal document flow, and the other elements inside will shift.
How does setting position: absolute on an element affect where it appears on the page?
It will appear relative to the closest non-static ancestor with the specified values of top, right, bottom, and left. (if none, it will be relative to the initial containing block)
Usually by default top left corner, but it does NOT matter since we always manipulate it by using box offset properties!
How do you constrain an absolutely positioned element to a containing block?
By making the containing block non-static.
- since least intrusive one is relative, we usually use RELATIVE
- OR making all other elements static?
What are the four box offset properties?
top, bottom, left, right
- acts like padding in PUSHING away the element from the specified box offset property
- use small measurements to keep the element close to the edge of desired position (for changing viewport!)
What are the 4 components of “the Cascade”
source order
inheritance
specificity
importance
List 3 selector types in order of increasing specificity
type class id
Why is using the !important rule considered bad practice?
It overrides EVERYTHING!
There is no other way to override it without using another !important.
*in other words, it is a non-verbal way to communicate that this is vital and SHOULD stay this way
:first-child
pseudo-class that represents the first element among a group of sibling elements
transform property and 4 functions
elements are rendered in a coordinate plane, this lets us adjust where the element falls within the coordinate plane. Shifting its origin point
-scale()
-translate()
-rotate()
-skew()
-matrix()
*allows movement without affecting size on 3 coordinate planes X, Y, Z
*acts within the same stacking context as positioning elements
meaning it can become a container for an position: fixed/absolute
ex) margin for button with pseudo-class behavior
vs. transform: translateY(0.25rem) for button with pseudo-class behavior