Selectors Flashcards
How to select the first paragraph of an article ?
article p:first-of-type {
}
What are the parts of a css rule ?
- 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.
What is the universal selector ?
A universal selector—also known as a wildcard—matches any element.
it is the star symbol (*).
What is a type selector ?
A type selector matches a HTML element directly.
example: section, article, p, etc.
What is a class selector ?
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.
What is an ID selector ?
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.
What is an attribute selector ?
An attribute selector matches elements that have a certain HTML attribute, or have a certain value for an HTML attribute
What is an attribute selector ?
An attribute selector matches elements that have a certain HTML attribute, or have a certain value for an HTML attribute
What is an attribute selector ?
An attribute selector matches elements that have a certain HTML attribute, or have a certain value for an HTML attribute
What is an attribute selector ?
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;
}
What is an attribute selector ?
An attribute selector matches elements that have a certain HTML attribute, or have a certain value for an HTML attribute
How to make attribute selector case sensitive ?
by adding an s operator to your attribute selector.
Exemple:
[data-type=’primary’ s] {
color: red;
}
How to make attribute selector case insensitive ?
by adding an i operator to your attribute selector.
Exemple:
[data-type=’primary’ i] {
color: red;
}
How to make an attribute selector match an attribute value that contains a string ?
Use the operator *=
/* A href that contains “example.com” /
[href=’example.com’] {
color: red;
}
How to make an attribute selector match an attribute value that starts with a string ?
Use the operator ^=
/* A href that starts with https */
[href^=’https’] {
color: green;
}