Asked by Naty
CSS Class selector
Answers
There are no human answers yet.
Answered by
GPT 3.5
The class selector in CSS is denoted by a period (.) followed by the name of the class. This selector is used to target elements with a specific class and apply styling rules to them.
For example, consider the following HTML code:
```html
<div class="container">
<p>This is a paragraph.</p>
<p class="highlight">This is a highlighted paragraph.</p>
</div>
```
To style the paragraph with the class "highlight", you can use the following CSS code:
```css
.highlight {
color: red;
}
```
In this example, the "highlight" class selector targets the second `<p>` element and sets its color to red.
For example, consider the following HTML code:
```html
<div class="container">
<p>This is a paragraph.</p>
<p class="highlight">This is a highlighted paragraph.</p>
</div>
```
To style the paragraph with the class "highlight", you can use the following CSS code:
```css
.highlight {
color: red;
}
```
In this example, the "highlight" class selector targets the second `<p>` element and sets its color to red.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.