Question:

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
collegedunia
Verified By Collegedunia

Solution and Explanation

Step 1: Understanding the Question:
Part one asks for the purpose of the style attribute. Part two asks for one line of code that makes a paragraph red.

Step 2: Purpose:
The style attribute is used to apply CSS rules directly to one HTML element. This is called inline CSS. It changes how that element looks, such as its colour, size or font.

Step 3: Build the code:
A paragraph uses the <p> tag. Inside it we add style="color:red;". The CSS property color sets the text colour and red is the value.

Step 4: Write the statement:
<p style="color:red;">This is a paragraph.</p>


Final Answer:
The style attribute gives inline CSS to one element, and color:red; makes the text red. \[ \boxed{\text{style attribute; color:red;}} \]
Was this answer helpful?
0
0

Top CBSE X Questions

View More Questions