Web Technologies - Old Questions

7.  How can you insert inline style sheet in the HTML document? Discuss with example.

5 marks | Asked in 2072

An inline CSS is used to apply a unique style to a single HTML element. An inline CSS uses the style attribute of an HTML element. To use inline CSS, we use the style attribute in the relevant tag.

E.g.

The following example sets the text color of the <h1> element to blue, and the text color of the <p> element to red:

<!DOCTYPE html>

<html>

<head>

<title>Inline CSS</title>

</head>

<body>

<h1 style="color:blue;">A Blue Heading</h1>

<p style="color:red;">A red paragraph.</p>

</body>

</html>