3/17/2022 Flashcards
Why do two div elements “vertically stack” on one another by default?
Because div elements are block elements by default and block elements start on a new line.
What is the default flex-direction of an element with display: flex?
The default flex-direction of an element with display: flex is row.
What are the four components of “the Cascade”.
- Source order
- Inheritance
- Specificity
- !important
What does the term “source order” mean with respect to CSS?
Source order refers to the order that rules are written in the CSS stylesheet. Source order determines that the last rule written for an element is the style that will be applied to that element.
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
Inheritance allows styles defined for a parent to be applied to its children as long as no style is already declared for a child.
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 difficult because it breaks the natural cascading in stylesheets due to !important overriding all other declarations.
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 affect document flow
How does setting position: relative on an element affect where it appears on the page?
It does not affect where it appears on the page. You can offset it with the top, right, bottom and left properties.
How does setting position: absolute on an element affect document flow?
position: absolute takes an element out of the normal flow and does not affect the position of the other elements on the page.
How does setting position: absolute on an element affect where it appears on the page?
It is positioned relative its closest positioned ancestor, if any. If it doesn’t have one, it is positioned relative to its initial containing block. It is offset using the top, right, bottom or left properties.
How do you constrain an absolutely positioned element to a containing block?
You set the position of the constraining block to position: relative.
What are the four box offset properties?
Top, right, bottom, and left.