CSS Flashcards
What are the names of the individual pieces of a CSS rule?
A CSS rule contains two parts: a selector and a declaration.
In CSS, how do you select elements by their class attribute?
To select elements with a specific class, write a period (.) character, followed by the name of the class.
In CSS, how do you select elements by their type?
The CSS type selector matches elements by node name. In other words, it selects all elements of the given type within a document.
In CSS, how do you select an element by its id attribute?
To select an element with a specific id, write a hash (#) character, followed by the id of the element.
Name three different types of values you can use to specify colors in CSS.
In CSS, colors can be specified by using hexadecimal values, color names, and rBGA values.
What CSS properties make up the box model?
The CSS properties that make up the box model are; padding, border, and margin.
Which CSS property pushes boxes away from each other?
The CSS property that pushes boxes away from each other is margin.
Which CSS property add space between a box’s content and its border?
The CSS property that adds space between a box’s content and its border is padding.
What is a pseudo-class?
A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s).
What are CSS pseudo-classes useful for?
Pseudo-classes let you apply a style to an element in relation to the content of the document tree, and; external factors like the history of the navigator, the status of its content, or the position of the mouse.
Name at least two units of type size in CSS.
In CSS, em and ex are examples of units of type size for text font.
What CSS property controls the font used for the text inside an element?
The CSS property that controls the font used for the text inside an element is called font-family.
What is the default flex-direction of a flex container?
The default flex-direction of a flex container is row.
What is the default flex-wrap of a flex container?
The default flex-wrap of a flex container is no wrap.
Why do two div elements “vertically stack” on one another by default?
Two div elements “vertically stack” on one another by default because a div is a block-level element.
What is the default flex-direction of an element with display: flex?
The default flex-direction of an element with display: flex is row.
What is the default value for the position property of HTML elements?
Static is always the initial value for the CSS property position.
How does setting position: relative on an element affect document flow?
Other content in the document is not affected by position: relative.
How does setting position: relative on an element affect where it appears on the page?
The element will move relative to its normal position.
How does setting position: absolute on an element affect document flow?
The element is removed from the document flow.
How does setting position: absolute on an element affect where it appears on the page?
It occupies it’s own layer and can appear on top of other elements.
How do you constrain an absolutely positioned element to a containing block?
Set all of its ancestor elements to have a position of static, which is the default value for the CSS property position.
What are the four box offset properties?
Top, bottom, left, and right.
What are the four components of “the Cascade”.
The four components of “the Cascade” are; last rule, specificity, importance, and inheritance.
What does the term “source order” mean with respect to CSS?
The term “source order” refers to the order in which styling is applied in CSS.
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
This is possible because of inheritance.
List the three selector types in order of increasing specificity.
Three selector types in order of increasing specificity are; *, h1, p#intro
Why is using !important considered bad practice?
It breaks the natural cascade and makes debugging harder
What does the transform property do?
It modifies the coordinate space of the CSS visual formatting model.
Give four examples of CSS transform functions.
Four CSS transform functions are; rotate, scale, skew, and translate.
The transition property is shorthand for which four CSS properties?
It is a shorthand for; transition-property , transition-duration , transition-timing-function , and transition-delay
Give two examples of media features that you can query in an @media rule.
Height and width of the viewport
Which HTML meta tag is used in mobile-responsive web pages?
Viewport meta tag
What is a breakpoint in responsive Web design?
In responsive design, a breakpoint is the “point” at which a website’s content and design will adapt in a certain way in order to provide the best possible user experience.
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?
The advantage is consistency in display across devices.
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?
Because of the last rule principle of the CSS cascade.