CSS Flashcards
What are the names of the individual pieces of a CSS rule?
A rule set has a selector and a declaration block
A declaration block consists of at least one declaration
A declaration is one property and one value
In CSS, how do you select elements by their”class”attribute?
“.className”
In CSS, how do you select elements by their type?
Just use the letters of the element without the “<>”, case sensitive
Separate by commas if grouping multiple (called a group selector)
In CSS, how do you select an element by itsid
attribute?
#elementID
Name three different types of values you can use to specify colors in CSS.
HEX codes
RGB (or RGBA with CSS3)
Names (white, black, blue, red)
HSLA (CSS3)
What CSS properties make up the box model?
Margin, border, padding
Technically the content is also part of the box model, so width and height can also be properties of the box model
Which CSS property pushes boxes 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 added to selectors to target elements under certain states
Class applied by the browser (not by the developer) under certain situations
What are CSS pseudo-classes useful for?
They can be useful for responding to users, altering behavior of elements that makes it easier for users to understand the intended uses. It also makes the page feel more responsive/interactive.
Style elements based not just on content but external factors to the content. (History, status, position)
Name two types of units that can be used to adjust “font-size” in CSS.
px, percentage (% of 16px, the default) rem, and ems (width of the letter “m”)
What CSS property controls the font used for the text inside an element?
“font-family”
What is the defaultflex-direction
of aflex
container?
The flex-direction
of a container will be row
by default, meaning items will be arranged horizontally from left-to-right
What is the default flex-wrap
of a flex
container?
It will be nowrap
by default, meaning all items will fit on one line.
What is the unit vh
?
Viewport height, 100vh is 100% of the viewport height.
Not commonly used because we don’t commonly set height with webpages.
May be used to set a container to be a certain height relative to the viewport rather than a height based on the content inside (centering an image on a page).
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)