Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Style an Element

DOM & Eventsmedium

Course · Section 7: JavaScript in the Browser: DOM and Events · Lecture 76: Selecting and Manipulating Elements

The page has a `<div id='box'>`. Set its text color to `red` using the inline style.

Sample tests

Input: the inline color is red
Output: assertion passes

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Inline styles override stylesheet rules; use them deliberately.

Learning resources

  • MDN: HTMLElement.style
Approach & explanation (try first)

Assigning style.color sets an inline style on the element.

Loading...
⌘/Ctrl + Enter

Run your code to see results.