css Flashcards
What are the names of the individual pieces of a CSS rule?
css selector and declaration / property and value
In CSS, how do you select elements by their class attribute?
with a . followed by class name
In CSS, how do you select elements by their type?
by simply typing the type name followed by the declaration
In CSS, how do you select an element by its id attribute?
with a # followed by ID name
Name three different types of values you can use to specify colors in CSS.
Hex code, RDB, and color name
What CSS properties make up the box model?
border, margin, padding
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 keyword that defines a special state of an element such as hover and focus
What are CSS pseudo-classes useful for?
changing the style of an element under a certain condition. EX: when mouse hovers button, change background to a different color.
Name at least two units of type size in CSS.
pixels, rem, em, and percentages
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 level 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?
it does not affect content flow.
How does setting position: relative on an element affect where it appears on the page?
the element stays the same.
How does setting position: absolute on an element affect document flow?
Absolute pulls the element out of the normal flow and all other content ignores the elements existence
How does setting position: absolute on an element affect where it appears on the page?
the element will appear at the top left of its first not-static parent element
How do you constrain an absolutely positioned element to a containing block?
by setting the containing block to position: relative and using the four box offset properties to position it relative to the containing block
What are the four box offset properties?
top, right, bottom, left
What are the four components of “the Cascade”.
Source order, inheritance, specificity and !important
What does the term “source order” mean with respect to CSS?
Refers to the order of elements in a style sheet. The styling that comes last in a style sheet will take priority.
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
Inheritance. Adding on styling to the parent element will cause its children to inherit that styling in certain cases.
List the three selector types in order of increasing specificity.
element, class, id.
Why is using !important considered bad practice?
It makes debugging more difficult by breaking the natural cascading order in a stylesheet.
What does the transform property do?
Transform property allows you to rotate, scale, skew, or translate an element.
Give four examples of CSS transform functions.
Rotate, translateX, translateY, translateZ, scale
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 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?
It allows the web pages to be responsive rather than adaptive. The element will grow/shrink as the screen will grow/shrink.
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?
Cascade/source order.