CSS Flashcards
What are the names of the individual pieces of a CSS rule?
Selector, Declaration Block, property, value
In CSS, how do you select elements by their class attribute?
.class
In CSS, how do you select elements by their type?
Use the element name
In CSS, how do you select an element by its id attribute?
id
Name three different types of values you can use to specify colors in CSS.
RGB Values: rgb(102,205,170)
Hex Codes: #66cdaa
Color Names: MediumAquaMarine
What CSS properties make up the box model?
Border, margin, padding
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)
What are CSS pseudo-classes useful for?
Pseudo-classes let you apply a style to an element not only in relation to the content of the document tree, but also in relation to external factors like the history of the navigator (:visited, for example), the status of its content (like :checked on certain form elements), or the position of the mouse (like :hover, which lets you know if the mouse is over an element or not).
Name at least two units of type size in CSS.
Pixels, percentages, ems
What CSS property controls the font used for the text inside an element?
font-family
What is the default flex-direction of a flex container?
Row (inline, x-axis)
What is the default flex-wrap of a flex container?
No wrap (inline)
What are the four components of “the Cascade”.
Source Order, Inheritance, !Important, Specificity
What does the term “source order” mean with respect to CSS?
Source order is the order that your CSS rules are written in your stylesheet. The one on the bottom has priority as long as all the types above it are the same
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 selector, class selector, id selector
Why is using !important considered bad practice?
It’s going to override everything else. It’s too powerful.
Why do two div elements “vertically stack” on one another by default?
Because they are block elements
What is the default flex-direction of an element with display: flex?
Row
What are the four components of “the Cascade”.
Source Order, Inheritance, !Important, Specificity
What does the term “source order” mean with respect to CSS?
Source order is the order that your CSS rules are written in your stylesheet. The one on the bottom has priority as long as all the types above it are the same
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 selector, class selector, id selector
Why is using !important considered bad practice?
It’s going to override everything else. It’s too powerful.
Why do two div elements “vertically stack” on one another by default?
Because they are block elements
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/normal
How does setting position: relative on an element affect document flow?
This does not affect the position of surrounding elements; they stay in the position they would be in normal flow.
How does setting position: relative on an element affect where it appears on the page?
It does not affect where it appears but it allows you to move it.
How does setting position: absolute on an element affect document flow?
the box is taken out of normal flow and no longer affects the position of other elements on the page.
How does setting position: absolute on an element affect where it appears on the page?
This positions the element in relation to its containing element. Absolutely positioned elements move as users scroll up and down the page.
How do you constrain an absolutely positioned element to a containing block?
Set containing block to non static (sticky absolute, relative, fixed)
What are the four box offset properties?
Top, bottom, left, right
What does the transform property do?
The transform CSS property lets you rotate, scale, skew, or translate an element
Give four examples of CSS transform functions.
Rotate, skew, scale, translate
The transition property is shorthand for which four CSS properties?
transition-property, transition-duration, transition-timing-function, and transition-delay
Give two examples of media features that you can query in an @media rule.
width
display-mode
Which HTML meta tag is used in mobile-responsive web pages?
Viewport meta tag
What is a breakpoint in responsive Web design?
Breakpoints are points where the website content responds according to the device width, allowing you to show the best possible layout to the user.
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’s more adaptable in relation to the size of the layout. Pixels are fixed and won’t change.
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 the selector at the bottom will take priority as long as the selector names are the same. Source order.