CSS Flashcards
What are the names of the individual pieces of a CSS rule?
selector; declaration with a property and value
In CSS, how do you select elements by their class attribute?
.classname
In CSS, how do you select elements by their type?
match element name
In CSS, how do you select an element by its id attribute?
idname
Three different types of values used to specify colors in CSS
RBG values, hex codes, color names
What CSS properties make up the box model?
border, margin, padding, height, width
Which CSS property pushes boxes away from each other?
margin
Which CSS property adds space between a box’s content and its border?
padding
What is a pseudo class?
a class applied by a browser that specifies a special state of the selected element
What are pseudo classes useful for?
applying style to an element in relation to external factors or events made by the user
Two types of units that can be used to adjust font-size in CSS
px, rem
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 (left to right)
What is the default flex-wrap of a flex container?
nowrap (all flex items are on one line)
Why do two div elements “vertically stack” on one another by default?
div elements are block elements
What is the default flex-direction of an element with display: flex?
row (left to right)
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 stays the same
How does setting position: relative on an element affect where it appears on the page?
it stays the same
How does setting position: absolute on an element affect document flow?
it gets removed from the document flow
How does setting position: absolute on an element affect where it appears on the page?
it gets positioned against non-static elements
How do you constrain an absolutely positioned element to a containing block?
set property as not static
What are the four box offset properties?
top, bottom, left, right
What are the four components of “the Cascade?”
- source order
- inheritance
- specificity
- !important
What does the term “source order” mean with respect to CSS?
styling towards the bottom is stronger and therefore 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?
inherited properties by default are set to the value of the parent element
List the three selector types in order of increasing specificity
- type selectors
- class selectors
- ID selectors
Why is using !important considered bad practice?
it will make debugging more difficult by breaking natural cascade in stylesheet
What does the transform property do?
lets you rotate, scale, skew, or translate an element by modifying the coordinate space
Give four examples of CSS transform functions.
- matrix
- scale
- rotate
- skew
Give two examples of media features that you can query in an @media rule.
- min-width
2. max-width
Which HTML meta tag is used in mobile-responsive web pages?
viewport
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?
the point at which you want to use media query to change design to cater to dimensions of different devices
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?
more accurate because % is used to define size as relative to element’s parent object
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?
- specificity; CSS source order still applies
- avoid this by putting min-width in ascending order