CSS Flashcards
What are the names of the individual pieces of a CSS rule?
one or more selectors, and a declaration block in curbraces, containing property/value pairs separated by semi-colons
- selector
- ruleset
- property/value pairs
In CSS, how do you select elements by their class attribute?
with .classname selector
In CSS, how do you select elements by their type?
with the element’s name
In CSS, how do you select an element by its id attribute?
with #idname selector
Name three different types of values you can use to specify colors in CSS.
- RGB values
- HEX codes
- color names
What CSS properties make up the box model?
- margin
- padding
- border
- content
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 pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s) (can be a user-prompted state or a passive relational state). ex: :hover, :focus, :playing, :visited, :nth-child(odd)
What are CSS pseudo-classes useful for?
- user feedback, allows changing of elements as user interacts with them
- responding to changing states of elements on the site
- selecting elements by various relationships, types, states
Name two types of units that can be used to adjust font-size in CSS.
- pixels, percentages, and ems (width of letter m)
- - rem (based on font size of root html element)
What CSS property controls the font used for the text inside an element?
font-family:
What are the four components of “the Cascade”
in decreasing order:
- 1 !importance
- 2 specificity
- 3 source order
- 4 inheritance
What does the term “source order” mean with respect to CSS?
–the order rules are written and read in CSS
Source order is, simply put, the order that your CSS rules are written in your stylesheet.
“…in a specificity tie, the last rule defined wins.”
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
inheritance
List the three selector types in order of increasing specificity.
- type selectors
- class selectors
- ID selectors
Why is using !important considered bad practice?
– it makes debugging more difficult because it breaks the natural cascading rules of a stylesheet
What is the default flex-direction of a flex container?
row: left to right
What is the default flex-wrap of a flex container?
nowrap (default): all flex items will be on one line
Why do two div elements “vertically stack” on one another by default?
bc divs are block elements that take up all their horizontal space
What is the default flex-direction of an element with display: flex?
row (ltr)
q) why does img {width: 100%} work?
- by default images will take up their full size.
- img {width: 100%} will constrain the image to the size of the container.
- this solves the problem of the image going beyond the container.
- requires the parent div to have a size set
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?
it does not
setting relative allows things to be moved, but doesn’t move anything itself