Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Class Selectors | Selecting and Targeting Elements
CSS Foundations

bookClass Selectors

index.html

index.html

style.css

style.css

copy

When you want to style several elements in the same way, you can give them a shared class. A class selector in CSS starts with a period (.) followed by the class name. This lets you target any element that has that class attribute. You can use the same class on as many elements as you like, making it easy to apply the same styles to multiple parts of your page. For example, if you add class="highlight" to different elements in your HTML, and then write .highlight { ... } in your CSS, all those elements will share the same style. This approach is flexible and makes your stylesheets more efficient and organized.

question mark

Which of the following is the correct syntax for selecting elements with a class named "highlight" in CSS?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 2

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Awesome!

Completion rate improved to 6.67

bookClass Selectors

Glissez pour afficher le menu

index.html

index.html

style.css

style.css

copy

When you want to style several elements in the same way, you can give them a shared class. A class selector in CSS starts with a period (.) followed by the class name. This lets you target any element that has that class attribute. You can use the same class on as many elements as you like, making it easy to apply the same styles to multiple parts of your page. For example, if you add class="highlight" to different elements in your HTML, and then write .highlight { ... } in your CSS, all those elements will share the same style. This approach is flexible and makes your stylesheets more efficient and organized.

question mark

Which of the following is the correct syntax for selecting elements with a class named "highlight" in CSS?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 2
some-alt