CSS Flashcards

1
Q

What declaration block should you use to add “cursor: pointer” to links when hovering over them?

A

a {}

Styling the cursor on a:hover {} can cause unwanted behaviors, while styling the cursor in the a {} block will still only modify the cursor when hovering.

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

What are the four main states of links? What are their associated pseudo-classes?

Bonus: In what order should their CSS rules be written for proper cascading?

A

Normal (not clicked), hover, active (clicked), and visited.

:link
:visited
:hover
:active

The above order properly cascades the link states.

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

What are the four layers of the box model?

A

From innermost to outermost:
- Content
- Padding
- Border
- Margin

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

What does the text-transform property determine?

Bonus: what are the four main values (including the default)?

A

The capitalization of text on the screen.

none: default value, no rule imposed
uppercase: text will be all-caps
lowercase: text will be no-caps
capitalize: the first letter of each word will be capitalized

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

What is the difference between the following selectors?

div p {}
div > p {}

A

The descendant selector (“div p {}”) will apply rules to any p element which descends from a div element.

The child selector (“div > p{}”) will only apply rules to p elements with a parent element of div.

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

What is the difference between the following selectors?

div + p {}
div ~ p{}

A

The adjacent sibling selector (“div + p {}”) will apply rules to any p elements which come immediately after a sibling div element.

The general sibling selector (“div ~ p {}”) will apply rules to any p elements which are at any point preceded by a sibling div element.

In other words: the adjacent sibling selector applies to elements which come directly after a specific sibling, while the general sibling selector applies to elements which come any time after a specific sibling.

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

What do the following selectors apply rules to?

p::before {}
p::after {}

A

They style any text inserted with the “content” property in that selector. In this example, text will be inserted immediately before or after p elements.

Example:

p::before {
content: “example text”;
color: red;
}

The above example will insert red text saying “example text” before all p elements. Note that the content property can be a reference, rather than a static string.

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