selectors Flashcards

1
Q

How do you select all html elements of the same type (e.g. span)?

A

The css selector is just the tag’s name. e.g.
span{

}

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

How do you select all elements on a page?

A

Star (*) selector e.g.:
*{
color:#aa2132;
}

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

How can you select all child elements of an HTML element?

A

Star selector after the tag selector. eg:
article *{
}

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

What is the * selector called?

A

Universal selector

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

Which elements are selected by
<code>
.some_name{</code>

}
</code>
?

A

All elements with attribute class=”some_name”

eg <div class="some_name"></div>

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

How do you select only those elements that have two classes applied? e.g.

<div></div>

?

A

concatenate the two class selectors e.g.
.note.warning{
}

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

How do you select elements by their id?
e.g. <div id="navigation"/>?

A

using #, e.g.
#navigation{

}

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

Which elements does a[alt] select?

A

all <a> elements with an alt attribute set, regardless of alt’s value, e.g. <a>Link</a></a>

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

What does [attr=value] select? e.g.

img[href=”https://prettypics.com/notanothercatpic.jpg”]?

A

Selects all elements that have the attribute “attr” and the attribute has the value “value”

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

What does [attr~=val] select? e.g. p[class~=”special”]?

A

Selects those attr’s that EITHER have EXACTLY the value “val”, OR contain val among their space separated possible list of values, e.g.

<p></p>

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

What does [attr|=value] select? e.g. div[lang|=”zh”]

A

it selects all elements with an attr attribute whose value is EXACTLY “value” OR begins with “value” immediately followed by a HYPHEN, i.e.

<div></div>

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

What does [attr^=value] select ?

A

Matches an element with an attribute(attr) whose value BEGINS with “value”

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

What does [attr$=value] select?

A

Matches elements with an attribute (attr) whose value ENDS with “value”

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

what does [attr*=value] select?

A

Matches those elements with an attribute (attr) whose value CONTAINS value

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

In attribute selectors, what does the “i” stand for? e.g. li[class^=”a” i]?

A

It selects all elements (li) with an attribute (class) that begins with the specified string (the letter a) but case INSENSITIVELY

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

What is a pseudo-class?

A

A pseudo-class is a selector that selects elements that are in a specific state, e.g. they are the first element of their type, or they are being hovered over by the mouse pointer. They tend to act as if you had applied a class to some part of your document, often helping you cut down on excess classes in your markup, and giving you more flexible, maintainable code.

17
Q

What is :first-child?

A

It is a pseudo-class which selects the first child of the element selected. e.g

article p:first-child{

}
selects the first child of type paragraph
within an article tag

18
Q

what does the :invalid pseudo-class selects?

A

All the elements that have failed to validate

19
Q

What do pseudo classes :link, :visited :hover, and :focus select?

A

These are dynamic pseudo classes which are applied when a user clicks a link, after the user has visited the link, while the last two apply if the user moves the cursor over any element, or when the user shifts focus to the element by clicking or using keyboard controls respectively

20
Q

What are ::first-line, ::before, ::after?

A

They are pseudo-elements. They act as if you had added a whole new HTML element into the markup, rather than applying a class to existing elements.

Pseudo-elements start with a double colon ::. ::before is an example of a pseudo-element.

21
Q

what is “>” in css selectors?

A

It is placed between two css selectors.
It matches only those elements matched by the second selector that are the direct children of elements matched by the first. Descendant elements further down the hierarchy don’t match.

22
Q

What does + between two CSS selectors select?

A

+ is the adjacent sibling combinator. It matches only those elements matched by the second selector that are the next sibling element of the first selector. For example, to select all <img></img> elements that are immediately preceded by a <p> element: p+img