Question:easy

Explain the purpose of the style attribute in HTML. Write an HTML statement to set the font color of a paragraph to "red" using inline CSS.

Show Hint

The style attribute holds CSS rules written as property:value;
Updated On: Nov 3, 2026
Show Solution

Solution and Explanation

Step 1: Say what style is for:
HTML gives structure. CSS gives looks. The style attribute lets us write CSS right inside a tag, so only that one element is changed.

Step 2: Write the CSS rule:
A rule has a property and a value separated by a colon, and ends with a semicolon. For text colour the rule is color:red;.

Step 3: Attach it to the paragraph:
<p style="color:red;">This is a paragraph.</p>

The words in this paragraph are shown in red. Other paragraphs stay as they were.

Step 4: Why inline CSS is useful:
Inline CSS is handy when only one element needs a special look, because we do not need a separate style sheet for it.

Final Answer:
Inline CSS with the style attribute turns the paragraph text red. \[ \boxed{\text{style attribute; color:red;}} \]
Was this answer helpful?
0