CSS Selectors Flashcards

1
Q

What does ul + p selector do?

A

Select only the first p that comes immediately after a ul.

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

What does ul ~ p selector do?

A

Select any p elements that are siblings to ul even if they don’t follow immediately. Doesn’t cover p elements that come before, however.

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

Find all images that end in .jpg

A

img [ src$=”jpg” ] (note: can’t have space between words)

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

Find all tags with a link that begins with “http”;

A

a[href^=”http”]

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

What is the pattern for finding elements based on attributes (not class or ID)? What if a word is first, last, or appears anywhere?

A

elementName[attr=value];

elName[attr^=value], *[attr$=value], etc.

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

Find all elements that have a style set on them by javascript no matter what type of element.

A

*[style]

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

Find all radio buttons that are checked

A

input[type=”radio”]:checked

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

Select every second item in a list

A

li:nth-child(2n);

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

Select just the second to last item in a list

A

li:nth-last-child(2);

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

Select every other child paragraph of a div

A

div > p:nth-of-type(2n)

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

Select the first, last, or only element in a collection.

A

:first-child | :first-of-type | :last-child | only-child

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

Select first letter or first line of a paragraph

A

::first-letter or ::first-line (note double color for pseudo elements)

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

Select all classes ending in “-area” (e.g. class=”title-area” or “content-area”)

A

[class$=”-area”] { …

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