CSS Flashcards

1
Q

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

A

Rule set, selector, declaration/declaration block, 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

With a dot/period ( . )

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 tag name?

A

With the tag/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

With the #.

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

Hexidecimal, rgba, hsla.

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

Height, width, padding, border, margin.

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 adds 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

A keyword added to a selector that specifies a special state of the selected element(s).

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

Giving additional information, additional functionality, and applying styles.

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

Name two types of units that can be used to adjust font-size in CSS.

A

Pixels, rem.

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

Default flex-direction is row.

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

Default flex-wrap is nowrap.

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

What does justify content do?

A

This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow the line.

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

What does align-items do?

A

This defines the default behavior for how flex items are laid out along the cross axis on the current line. Think of it as the justify-content version for the cross-axis (perpendicular to the main-axis).

17
Q

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

A

They are block-level elements.

18
Q

What is the default flex-direction of an element with display: flex?

A

Row.

19
Q

What are the three primary components of a page layout? (Which helper classes do you need?)

A

Container class/element, row class/element, column class/element.

20
Q

What is the minimum number of columns that you should put in a row?

A

One.

21
Q

What is the purpose of a container?

A

To hold the row class/element, and the column class/element. (Also to provide additional styling/functionality).

22
Q

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

A

Default position property is Static.

23
Q

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

A

Relative position moves an element in relation to where it would have been in normal flow. (Document flow is unaffected).

24
Q

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

A

Position: relative will have no affect until a box offset property is set. It will then move relative to where it would have been in normal flow.

25
Q

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

A

The box (element) is taken out of normal flow and no longer affects the position of other elements on the page. (They act like it is not there.)

26
Q

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

A

The element is taken out of normal flow, then the box offset properties can specify where the element should appear in relation to its containing element.
(Taken out of normal flow “above” other elements,
in relation to closest non-static ancestor.)

27
Q

What are the four box offset properties?

A

Top, bottom, left, right.

28
Q

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

A

Assign anything expect position static to the containing block.

29
Q

What are the four components of “the Cascade”.

A
  • Inheritance.
  • Specificity.
    -Source-order.
  • !important (rule).
30
Q

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

A
  • The priority/strength is given to rules lower down the style sheet.
31
Q

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

A
  • Font and text are inherited properites.
32
Q

List the three selector types in order of increasing specificity.

A
  • Element.
  • Class.
  • ID.
33
Q

Why is using !important considered bad practice?

A
  • Has extremely high specificity so it is very hard to override.

Bonus: (Two main reasons why it exists):
- Working inside a premade template that has a style that needs to be over ridden. (Like wordpress).
- If you are making a CSS library.