CSS Flashcards

1
Q

What are the names of the individual pieces of a CSS rule?

A

Selector, declaration block, declaration(s) {property: value};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In CSS, how do you select elements by their class attribute?

A

.class or element.class { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In CSS, how do you select elements by their type?

A

element name { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In CSS, how do you select an element by its id attribute?

A

id { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Name three different types of values you can use to specify colors in CSS.

A
o	RGB Value
o	Hex Code
o	Color Name
o	RGBA (RGB + opacity)
o	HSL
o	HSLA (HSL + opacity)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What CSS properties make up the box model?

A

margin, border, padding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which CSS property pushes boxes away from each other?

A

margin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which CSS property add space between a box’s content and its border?

A

padding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a pseudo-class?

A

keyword added to a CSS selector that specifies a special state of the selected element(s), can apply a style that is applied by the browser when the condition is met

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are CSS pseudo-classes useful for?

A

o Style an element when a user mouses over it
o Style visited and unvisited links differently
o Style an element when it gets focus
o Style an element based on position in a group of siblings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Name at least two units of type size in CSS.

A

pixels, ems, percentages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What CSS property controls the font used for the text inside an element?

A

font-family

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the default flex-direction of a flex container?

A

row: left to right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the default flex-wrap of a flex container?

A

nowrap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why do two div elements “vertically stack” on one another by default?

A

they are block level elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the default value for the position property of HTML elements?

A

position: static

17
Q

How does setting position: relative on an element affect document flow?

A

Does not affect document flow, other elements will act as if it hasn’t moved.

18
Q

How does setting position: relative on an element affect where it appears on the page?

A

Nothing changes unless positioned (relative to the space it would have occupied in normal document flow).

19
Q

How does setting position: absolute on an element affect document flow?

A

Element is removed from the normal document flow and sits on its own layer separate from everything else.

20
Q

How does setting position: absolute on an element affect where it appears on the page?

A

Positioned in relation the first ancestor element that has it’s position set to anything other than static, if none, will position to the html element.

21
Q

How do you constrain an absolutely positioned element to a containing block?

A

Set position: relative to the parent element

22
Q

What are the four box offset properties?

A

top, right, bottom, left

23
Q

What are the four components of “the Cascade”.

A

o Source order
o Inheritance
o Specificity
o !Important

24
Q

What does the term “source order” mean with respect to CSS?

A

The order in which the CSS rules are written in the stylesheet, last highest priority.

25
Q

How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?

A

Inheritance

26
Q

List the three selector types in order of increasing specificity.

A

o Element type
o Class
o ID

27
Q

Why is using !important considered bad practice?

A

Breaks the cascade flow of the stylesheet and makes debugging difficult

28
Q

What does the transform property do?

A

lets you rotate, scale, skew, or translate an element (adjust the coordinate plane)

29
Q

Give four examples of CSS transform functions.

A
o	rotate() Rotates an element around a fixed point on the 2D plane.
o	scale() Scales an element up or down on the 2D plane.
o	skew() Skews an element on the 2D plane.
o	translate() Translates(moves) an element on the 2D plane.
30
Q

The transition property is shorthand for which four CSS properties?

A

o transition-property sets the CSS properties to which a transition effect should be applied
o transition-duration sets the length of time a transition animation should take to complete
o transition-timing-function how intermediate values are calculated for CSS properties being affected by a transition effect
o transition-delay the duration to wait before starting a property’s transition effect when the value changes

31
Q

Give two examples of media features that you can query in an @media rule.

A

o width or height (of the viewport)

o orientation

32
Q

Which HTML meta tag is used in mobile-responsive web pages?

A

viewport < meta name=”viewport” content=”width=device-width, initial-scale=1” >

33
Q

What is a breakpoint in responsive Web design?

A

The point where a media query is introduced

34
Q

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?

A

Because viewport size and pixel density can vary greatly, relative units like percents are more flexible, ie making something 50% wide means it will always take up half of the viewport no matter what size the viewport is.

35
Q

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?

A

Source order: last rule has highest priority.