Write a program to create a webpage to print your city name in red color.
Description: Create a web page that prints the name of your city in red colour.
Hint:
- Use the
styleattribute with the CSScolorproperty. - The old
<font color="red">tag is not valid in HTML5.
HTML program to print a city name in red
<!DOCTYPE html>
<html lang="en">
<head>
<title>My City</title>
</head>
<body>
<h1 style="color: red;">Delhi</h1>
</body>
</html>
Output in the browser:
Output in the browser
Delhi
How it works
- The
styleattribute holds CSS for this element only. color: red;changes the text colour to red. You can also use a hex code like#ff0000.
Learn more in HTML Styles.
Learn more about the similar topics:
| Tutorials |
|---|
| HTML Elements and Tags |
| Interview Questions & Answers |
|---|
| Do all HTML tags require both a begin and end tag? |