CSS Selectors Flashcards

1
Q

What selector can you use to to apply CSS styling to every element on the page

A

The Universal Selector. e.g. * {
border: 2px solid black;
}

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

What can you think of an HTML document like?

A

A tree where elements branch out from the Trunk

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

An element is a child of what?

A

An element is a child of EVERY element wrapped around it, even if that element is several “branches” away!

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

The Tag is like a what on a tree

A

Trunk

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

What are the immediate branches of the HTML tag or Trunk

A

Head and Body or it’s children

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

How can you grab direct children—that is, an element that is directly nested inside another element, with no elements in between

A

> e.g. div > p { /* Some CSS */ }

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

When will certain selectors override others?

A

if they have a greater specificity value. ul li p { is more specific CSS than just p {, so when CSS sees tags that are both <p> tags and happen to be inside unordered lists, it will apply the more specific styling (ul li p {) to the text inside the lists.

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

What are the two selectors that are more specific than nested selectors?

A

Classes and IDs

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

How are classes assigned to elements?

A

with the word class and an equals sign. <div class="square"></div>

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

How are classes identified in CSS

A

With a dot.

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

When is it a good idea to use an ID

A

When there is ONE element that needs styling

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

How are IDs assigned

A

With the word id and the =

e.g. <div></div>

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

How are IDs identified?

A

With a # sign. e.g. #serious

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

What is a pseudo-class selector?

A

way of accessing HTML items that aren’t part of the document tree

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

What’s a use case for a pseudo-class selector

A

you can control the appearance of unvisited and visited links—even links the user is hovering over but hasn’t clicked!

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

What is the syntax for pseudo-class selectors?

A

selector:pseudo-class_selector {
property: value;
}

17
Q

What pseudo-class selector is used to apply styling to only the elements that are the first children of their parents.

A

first-child selector

18
Q

What pseudo-class selector is used to apply styling after the 1st element>

A

nth-child selector

E.g. p:nth-child(2) {
color: red;
}

19
Q

What is the difference between an ID and a class?

A

An ID can be used to identify one element, whereas a class can be used to identify more than one.