Selectors Flashcards

1
Q

How to select the first paragraph of an article ?

A

article p:first-of-type {

}

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

What are the parts of a css rule ?

A
  • A selector or a set of selectors
  • A set of declarations enclosed within curly brackets. Each declaction is formed by a key/value pair where the key is also called the property.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the universal selector ?

A

A universal selector—also known as a wildcard—matches any element.

it is the star symbol (*).

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

What is a type selector ?

A

A type selector matches a HTML element directly.

example: section, article, p, etc.

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

What is a class selector ?

A

A class selector matches any element that has that class applied to it.

A class selector starts with a dot (.) followed by the name of the class to select.

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

What is an ID selector ?

A

An ID selector matches the only element on a page with that ID value.

An ID selector starts with a sharp(#) followed by id to select.

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

What is an attribute selector ?

A

An attribute selector matches elements that have a certain HTML attribute, or have a certain value for an HTML attribute

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

What is an attribute selector ?

A

An attribute selector matches elements that have a certain HTML attribute, or have a certain value for an HTML attribute

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

What is an attribute selector ?

A

An attribute selector matches elements that have a certain HTML attribute, or have a certain value for an HTML attribute

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

What is an attribute selector ?

A

An attribute selector matches elements that have a certain HTML attribute, or have a certain value for an HTML attribute

Example:

[data-type=’primary’] {
color: red;
}

[data-type] {
color: red;
}

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

What is an attribute selector ?

A

An attribute selector matches elements that have a certain HTML attribute, or have a certain value for an HTML attribute

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

How to make attribute selector case sensitive ?

A

by adding an s operator to your attribute selector.

Exemple:

[data-type=’primary’ s] {
color: red;
}

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

How to make attribute selector case insensitive ?

A

by adding an i operator to your attribute selector.

Exemple:

[data-type=’primary’ i] {
color: red;
}

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

How to make an attribute selector match an attribute value that contains a string ?

A

Use the operator *=

/* A href that contains “example.com” /
[href
=’example.com’] {
color: red;
}

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

How to make an attribute selector match an attribute value that starts with a string ?

A

Use the operator ^=

/* A href that starts with https */
[href^=’https’] {
color: green;
}

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

How to make an attribute selector match an attribute value that ends with a string ?

A

Use the operator $=

/* A href that starts with https */
[href$=’https’] {
color: green;
}

14
Q

What is the difference between pseudo-elements and pseudo-classes ?

A

Pseudo-elements differ from pseudo-classes because instead of responding to the platform state, they act as if they are inserting a new element with CSS. Pseudo-elements are also syntactically different from pseudo-classes, because instead of using a single colon (:), we use a double colon (::).

15
Q

How to insert content at the start of an element using css ?

A

.my-element::before {
content: ‘Prefix - ‘;
}

16
Q

How to style bullet points of an html list ?

A

/* Your list will now either have red dots, or red numbers */
li::marker {
color: red;
}

17
Q

How to style a content that has been highlighted by the user ?

A

::selection {
background: black;
color: white;
}

18
Q

What is a css combinator ?

A

A combinator is what sits between two selectors. For example, if the selector was p > strong, the combinator is the > character.

19
Q

What is the descendant combinator ?

A

It is the space “ “
A descendant combinator allows us to target a child element. This uses a space ( ) to instruct the browser to look for child elements.
The descendant combinator is recursive.

Example:

p strong {
color: blue;
}

20
Q

What is the Next sibling combinator ?

A

it is the plus sign “+”

The next sibling combinator allows us to target an element that immediately follows another element

21
Q

What is the Subsequent- sibling combinator ?

A

It is the tild sign “~”

The subsequent sibling combinator allows us to target an element that just has to follow another element with the same parent, rather than being the next element with the same parent.

22
Q

What is the Child combinator ?

A

It is the superior sign (>)

It allows you more control over the recursion that comes with combinator selectors. By using the > character, you limit the combinator selector to apply only to direct children.

23
Q

What is a compound combinator ?

A

When 2 or more selectors are used together, without a combinator, in order to create a more specific selector.