Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Changing Inline Styles | Modifying and Styling the DOM
DOM Manipulation with JavaScript

bookChanging Inline Styles

To change the appearance of elements on your web page using JavaScript, you can directly modify their inline styles with the style property. Every DOM element has a style object, which lets you set individual CSS properties using JavaScript syntax. When you assign a value to a property of the style object, such as element.style.color = "red", you are setting that style directly on the element.

Property names are written in camelCase, so for example, background-color in CSS becomes backgroundColor in JavaScript. This way, you can dynamically adjust the look and feel of your page based on user actions or other conditions.

index.html

index.html

script.js

script.js

copy
question mark

Which of the following is the correct way to change the text color of an element with the variable name myElement to blue using JavaScript?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 3

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

bookChanging Inline Styles

Glissez pour afficher le menu

To change the appearance of elements on your web page using JavaScript, you can directly modify their inline styles with the style property. Every DOM element has a style object, which lets you set individual CSS properties using JavaScript syntax. When you assign a value to a property of the style object, such as element.style.color = "red", you are setting that style directly on the element.

Property names are written in camelCase, so for example, background-color in CSS becomes backgroundColor in JavaScript. This way, you can dynamically adjust the look and feel of your page based on user actions or other conditions.

index.html

index.html

script.js

script.js

copy
question mark

Which of the following is the correct way to change the text color of an element with the variable name myElement to blue using JavaScript?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 3
some-alt