CSS Flashcards
What are the names of the individual pieces of a CSS rule?
properties, declaration block, selector, value
In CSS, how do you select elements by their class attribute?
.class
In CSS, how do you select elements by their type?
Element-name (h1, body, article)
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.
Hex codes, rgb values, and color names (less often: rgba)
What is the box model?
common interview question
how css interprets a box including margin, border, and padding
What CSS properties make up the box model?
Margin, border, 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?
It’s a keyword added to a selector that specifies a special state of the selected element(s)
What are CSS pseudo-classes useful for?
They apply a style to elements when interacted with by the user
Name at least two units of type size in CSS.
Pixels, percentages, and ems
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?
nowrap
Why do two div elements “vertically stack” on one another by default?
Div elements 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?
It doesn’t affect document flow.
How does setting position: relative on an element affect where it appears on the page?
It’s position is relative to where it’s normal placement
How does setting position: absolute on an element affect document flow?
The document acts like it doesn’t exist to other elements surrounding it
How does setting position: absolute on an element affect where it appears on the page?
Will position that element within the nearest non static parent if not the vp
How do you constrain an absolutely positioned element to a containing block?
You can control where it is positioned by placing it within a non static positioned element
What are the four box offset properties?
Top, bottom, left, right
What are the four components of “the Cascade”.
Source order, inheritance, specificity, !important
What does the term “source order” mean with respect to CSS?
If multiple rules affect the same element then the latter rule in the stylesheet takes precedence over rules above that rule
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
If property isn’t an inherited property, then you can give that property a value of “inherit”
List the three selector types in order of increasing specificity.
Id selectors > class selectors/attributes selectors/pseudo-classes > type selectors, pseudo-elements
Why is using !important considered bad practice?
It’s bad practice because it can be hard to debug.
What does the transform property do?
It lets you rotate, scale, skew, or translate an element
Give four examples of CSS transform functions.
Translate, scale, skew, rotate, matrix, perspective
The transition property is shorthand for which four CSS properties?
Transition-property, transition-duration, transition-timing-function, and transition-delay.
Give two examples of media features that you can query in an @media rule.
Max-width and min-width
Which HTML meta tag is used in mobile-responsive web pages?
meta name=”viewport” content=”width=device-width, initial-scale=1”
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 for more flexibility and will work for variety of different vp 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 comes later in the cascade source order so it is applied over the rule above it.
Give two examples of media features that you can query in an @media rule.
Max-width and min-width
Which HTML meta tag is used in mobile-responsive web pages?
meta name=”viewport” content=”width=device-width, initial-scale=1”