CSS Flashcards
What are the names of the individual pieces of a CSS rule?
selector and declaration block
In CSS, how do you select elements by their class attribute?
by putting a . Infront of the name
In CSS, how do you select elements by their type?
put the name of the element
In CSS, how do you select an element by its id attribute?
put a # Infront of the name
Name three different types of values you can use to specify colors in CSS.
rbg, hex, and name
What CSS properties make up the box model?
border, padding and margin
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?
CSS pseudo-classes are used to add styles to selectors, but only when those selectors meet certain conditions.
What are CSS pseudo-classes useful for?
A pseudo-class is used to define a special state of an element. For example, it can be used to: Style an element when a user mouses over it. Style visited and unvisited links differently.
Name two types of units that can be used to adjust font-size in CSS.
px and em
What CSS property controls the font used for the text inside an element?
font-property
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?
they are designed to take up the entire width of the page so the next moves to the next line
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?
keeps its location but is now ignored by other elements
How does setting position: relative on an element affect where it appears on the page?
keeps its location but is now ignored by other elements
How does setting position: absolute on an element affect document flow?
ignored by all elements of the page
How does setting position: absolute on an element affect where it appears on the page?
it sits on its own layer separate from everything else, bringing it to the top left start
How do you constrain an absolutely positioned element to a containing block?
set the blocks position to relative
What are the four box offset properties?
left, right, top, bottom
What are the four components of “the Cascade”.
source order, inheritance, specificity, importance
What does the term “source order” mean with respect to CSS?
Items in a container are sorted by ascending order value and then by their source code order.
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.
- , *.class, #id
Why is using !important considered bad practice?
because it doesn’t play by the rules of cascading style sheets and makes things difficult to change because you have to overwrite importance.
What does the transform property do?
applies a 2D or 3D transformation to an element
Give four examples of CSS transform functions.
scale, matrix, rotate, translate
The transition property is shorthand for which four CSS properties?
transition-property, transition-duration, transition-timing-function, transition-delay
What is a breakpoint in responsive Web design?
where media rules start working, at what point the layout changes
What is the advantage of using a percentage (e.g. 50%) width instead of a fixed (e.g. px) width for a “column” class in a responsive layout?
it allows for variance and makes boundaries that don’t need to be exact
If you introduce CSS rules for a smaller min-width after the styles for a larger min-width in your style sheet, the CSS rules for the smaller min-width will “win”. Why is that?
because of source order