CSS Flashcards
What are the names of the individual pieces of a CSS rule?
the selector and the declaration
In CSS, how do you select elements by their class attribute?
with the period followed by the name
n CSS, how do you select elements by their type?
with the elementname
In CSS, how do you select an element by its id attribute?
with the pound sign (#) followed by the name
Name three different types of values you can use to specify colors in CSS.
rgb, rgba, hsla, hex colors, color name
What CSS properties make up the box model?
margins, border, padding, and actual 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?
a selector that specifies a special state of the selected element.
What are CSS pseudo-classes useful for?
they let you apply style to elements in different states.
How to read
table.striped thead > tr
rule set for tr elements that are direct children of thead in the table element with the striped class
Name at least two units of type size in CSS.
pixels , percentage , em , 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
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 they appear in the css style sheet
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 selectors, class selectors, id selectors
Why is using !important considered bad practice?
it breaks the natural cascading in your style sheets. overrides other declarations
Why do two div elements “vertically stack” on one another by default?
they are block elements that every new one starts on a new line
What is the default flex-direction of an element with display: flex?
the default flex-direction is: row
What is the default value for the position property of HTML elements?
position: static
How does setting position: relative on an element affect document flow?
It does not affect the normal flow of other elements on the page
How does setting position: relative on an element affect where it appears on the page?
Relative positioning moves an
element in relation to where it
would have been in normal flow.
/it doesn’t affect its position unless you change the position
How does setting position: absolute on an element affect document flow?
It affects the other elements as the other elements treat it as if it wasn’t there. The absolute element is treated as if it wasn’t there and the other elements take its position
How does setting position: absolute on an element affect where it appears on the page?
it now appears on its own layer and can be moved without affecting the other elements around it
How do you constrain an absolutely positioned element to a containing block?
by setting the parents position to relative or a non-static position / though depending on what the parent is it changes how the parent shows up on the page
What are the four box offset properties?
top , bottom , left , right
What does the transform property do?
it lets you modify the html elements
Give four examples of CSS transform functions.
rotate, scale, skew, translate
The transition property is shorthand for which four CSS properties?
transition-delay
transition-duration
transition-property
transition-timing-function
Give two examples of media features that you can query in an @media rule.
max-width: min-width / orientation
Which HTML meta tag is used in mobile-responsive web pages?
meta-viewport tag
What is a breakpoint in responsive Web design?
CSS breakpoints are points where the website content responds according to the 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?
its more responsive and not fixed / apply to different screen sizes
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?
it is the last rule as in CSS it is cascading . In that the last rule is the one that wins