Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre ID Selectors | Selectors and Cascade
Introduction to CSS Part I

bookID Selectors

We have learned that in CSS, selectors select elements from DOM and then apply style rules as specified for them. These selectors can be of various types, and one of them is an id selector that is used to select and style a single element on a web page. It is identified by the # symbol followed by the unique id attribute of the element. Here is an example of using an id selector in CSS:

#header {
  background-color: blue;
  color: white;
  font-size: 24px;
}
index.html

index.html

index.css

index.css

copy

In this example, the <div> element has an id attribute of the "header", so it will be styled according to the rules defined in the #header selector in the CSS.

You can also use the id selector in combination with other selectors to create more specific rules. For example:

#header h1{
  font-style: italic;
}
index.html

index.html

index.css

index.css

copy

In this example, the #header h1 selector selects all h1 elements that are descendants of an element with the id attribute of "header". This allows you to apply styles specifically to the h1 elements within the "header" element.

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 1

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

Suggested prompts:

Posez-moi des questions sur ce sujet

Résumer ce chapitre

Afficher des exemples du monde réel

Awesome!

Completion rate improved to 5.26

bookID Selectors

Glissez pour afficher le menu

We have learned that in CSS, selectors select elements from DOM and then apply style rules as specified for them. These selectors can be of various types, and one of them is an id selector that is used to select and style a single element on a web page. It is identified by the # symbol followed by the unique id attribute of the element. Here is an example of using an id selector in CSS:

#header {
  background-color: blue;
  color: white;
  font-size: 24px;
}
index.html

index.html

index.css

index.css

copy

In this example, the <div> element has an id attribute of the "header", so it will be styled according to the rules defined in the #header selector in the CSS.

You can also use the id selector in combination with other selectors to create more specific rules. For example:

#header h1{
  font-style: italic;
}
index.html

index.html

index.css

index.css

copy

In this example, the #header h1 selector selects all h1 elements that are descendants of an element with the id attribute of "header". This allows you to apply styles specifically to the h1 elements within the "header" element.

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 1
some-alt