CSS Flashcards
What are the names of the individual pieces of a CSS rule?
selector and declaration block- within block is a property assigned a value (separated by semicolon)
ex) p {color:red}
In CSS, how do you select elements by their class attribute?
class attribute is .classname
In CSS, how do you select elements by their type?
element name ex) h1, h2, body, p
In CSS, how do you select an element by its id attribute?
id attribute is #idname
Name three different types of values you can use to specify colors in CSS.
Hex code, rgb vaules, color names
What CSS properties make up the box model?
margin, padding, border, content
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?
classes applied by the browser under certain conditions [keyword added to a selector for when a special event occurs (hover, focus, active)]
What are CSS pseudo-classes useful for?
apply style, user interaction
Name at least two units of type 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
What is the default flex-wrap of a flex container?
no wrap
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
How does setting position: relative on an element affect document flow?
moves element in relation to where it would be in a normal document flow
How does setting position: relative on an element affect where it appears on the page?
stays in same place unless value of top, bottom, left, right are changed
How does setting position: absolute on an element affect document flow?
taken out of flow, so other elements act as if its no longer there (on its own layer)
How does setting position: absolute on an element affect where it appears on the page?
sits on top of non-static ancestor (on its own layer)
How do you constrain an absolutely positioned element to a containing block?
it needs to be on an element without a static position
What are the four components of “the Cascade”.
source order, inheritance, specificity, !important
What does the term “source order” mean with respect to CSS?
the order that you put rulesets in your styling sheet
styling that come later supersedes other
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
inheritance of parent element styles
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 more difficult and breaks natural cascading in stylesheet
What does the transform property do?
modifies the element
Give four examples of CSS transform functions.
rotate, scale, skew, or translate an element
The transition property is shorthand for which four CSS properties?
delay, duration. property, timing-function
Give two examples of media features that you can query in an @media rule.
min-width max-width
Which HTML meta tag is used in mobile-responsive web pages?
viewport
What is a breakpoint in responsive Web design?
point where new styling changes occur (changing things based off of viewport/device width)
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?
percentages are more flexible than px and easier to work with
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?
cascading, source order