Welcome to the lesson on using colors in HTML! You can change the color of text to make it more appealing or to highlight important information.
To change the color of text in HTML, you can use the style attribute within the HTML elements. Here’s how you can do it:
<p style="color: red;"> tag for paragraph text.<h1 style="color: blue;"> tag for headings.Let’s see an example in code:
<!DOCTYPE html>
<html>
<head>
<title>Colored Text</title>
</head>
<body>
<h1 style="color: blue;">This is a Blue Heading</h1>
<p style="color: red;">This is a red paragraph.</p>
<p style="color: green;">This is a green paragraph.</p>
<p style="color: #FFA500;">This is an orange paragraph.</p>
</body>
</html>
When you run this code, you'll see text displayed in different colors!
Type the code below and click "Run" to see how it works:
Create a paragraph that says "This text is red." and make it red.
Create a paragraph that says "This text is green." and make it green.
Create a paragraph that says "This text is blue." and make it blue.
Create a paragraph that says "This text is orange." and make it orange.
Create a paragraph that says "This text is purple." and make it purple.