Subject: Class Selector
Author: CyberSpider
In response to: Element Type Selector
Posted on: 04/12/2016 05:41:22 AM
Class selector preceded by '.' is used to find all elements of the same class.
.blue_underline {
color: blue;
text-decoration: underline;
}
Try it yourself in sandbox »
>
> On 04/11/2016 06:46:54 PM
CyberSpider wrote:
The element type selector is used to find elements with the corresponding element type name.
p {
text-align: center;
color: green;
}
Try it yourself in sandbox »
The above style is going to apply unto all <p> elements within the HTML document.
To narrow down the scope to find the element, the path can be used:
A E -- any E element that is descendant of element A;
P > E -- any E element that is child of element P;
S + E -- any E element that is immediately preceded by a sibling element S.
table td {
color: green;
}
tr > td {
text-decoration: line-through;
}
table + p {
background-color: red;
}
Try it yourself in sandbox »
References: