CSS Flashcards
what are the names of the individual pieces of a CSS rule?
Selector, declaration, property, and value
In CSS, how do you select elements by their class attribute?
.class { }
in CSS, how do you select elements by their type
typename { }
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, Hex codes, Color Names
What CSS properties make up the box model?
PBM - padding, border, margin
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 pseud-class?
keyword added to a selector that specifies a special state of the selected element(s)
what are CSS pseudo-classes useful for?
special situations (nth-child)
name at least two units of type size in CSS
em (relative to the font-size of direct or nearest parent) , rem (only relative to the html root font-size)
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 will be on one line)
why do two div elements “vertically stack” on one another by default?
div is block element and will appear on new line
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 (normal flow)
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 (does not affect document flow)
how does setting position: relative on an element affect where it appears on the page?
nothing changes
how does setting position: absolute on an element affect document flow?
absolute positioning removes document flow and ignores surrounding elements
how does setting position: absolute on an element affect where it appears on the page?
absolute is for layering elements on top of other elements
how do you constrain an absolutely positioned element to a containing block?
position: relative or non-static parent
what are the four box offset properties?
top, left, right, bottom
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 your CSS rules are written in your stylesheet
how is it possible for the styles of an element to be applied to its children as well an additional CSS rule?
inheritance
list the three selector types in order of increasing specifcity
type, class, ID
why is using !important considered bad practice
makes debugging more difficult by breaking the natural cascading in your stylesheets
what does the transform property do?
lets you rotate, scale, skew, or translate an element. it modifies the coordinate space of the CSS visual formatting model
give four examples of CSS functions
translate()
scale()
rotate()
skew()
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
width
orientation
which HTML meta tag is used in mobile-responsive web pages
viewport
what is a breakpoint in responsive web design
the points at which a media query is introduced
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?
% changes element size relative to parent and your page will dynamically change to fit
if you introduce CSS rules for a smaller min-width after the styles for a large min-width, the CSS rules for the smaller min width will “win.” why is that?
the rule that occurs last takes precedence in the cascade
source order