CSS Flashcards
What are the names of the individual pieces of a CSS rule?
A CSS rule contains two parts: a selector and a declaration.
In CSS, how do you select elements by their class attribute?
With a full stop symbol (a.k.a. A period) then the name/value assigned to the class attribute
In CSS, how do you select elements by their type?
The selector matches the element’s name and is just that
In CSS, how do you select an element by its id attribute?
With a # (pound, hash symbol) then the name/value assigned to the id attribute
Name three different types of values you can use to specify colors in CSS.
RGB Values, HEX Codes, Color Names, HSL Functional Notation
What CSS properties make up the box model?
Margin, padding, border, and the content (content typically referred to in 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 keyword added to a selector that specifies a special state of the selected element(s) (e.g. :link, :visited, :hover,
:focus, :active)
What are CSS pseudo-classes useful for?
They allow you to apply a style/ change the appearance of elements when a user is interacting with them.
Name at least two units of type size in CSS.
Pixels (px), point (pt), percentages (%), ems (em)- equivalent to the size of a letter m)
What CSS property controls the font used for the text inside an element?
The font-family property
What is the default flex-direction of a flex container?
Row is the default flex-direction
What is the default flex-wrap of a flex container?
Nowrap is the default flex-wrap; all flex items will be on one line
Why do two div elements “vertically stack” on one another by default?
Because the grid arranges a box or group of boxes across the page horizontally forming rows. From there, each row can then be divided into one or more columns.
What is the default flex-direction of an element with display: flex?
Row is the default flex-direction
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 the document flow and all other elements will behave as if the relative element hasn’t moved.
How does setting position: relative on an element affect where it appears on the page?
Relative positioning moves an element in relation to where it would have been in normal flow.
How does setting position: absolute on an element affect document flow?
Absolute elements are removed from the normal document flow (they don’t affect and aren’t affected by other elements in the page).
How does setting position: absolute on an element affect where it appears on the page?
The box offset properties (top or bottom and left or right) specify where the element should appear in relation to its containing element.
How do you constrain an absolutely positioned element to a containing block?
Assigning the position property of the containing block/parent to anything other than ‘static’ will constrain an absolute positioned element to that containing block.
What are the four box offset properties?
Top or bottom and left or right
What are the four components of “the Cascade”.
Source order, inheritance, specificity, importance
What does the term “source order” mean with respect to CSS?
It’s the order in which CSS styling rules are written in your stylesheet and determines which style ultimately gets applied.
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
The value of those properties is inherited by the child element(s).
List the three selector types in order of increasing specificity.
id selectors > .class selectors > element / type selectors
Why is using !important considered bad practice?
This declaration overrides any other declarations and it makes debugging more difficult by breaking the natural cascading in your stylesheets.