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 style attribute with the CSS color property.
  • 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 style attribute 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 Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Comments
HTML Symbols
Exercises & Assignments
Program to see difference between paragraphs & normal text with line break
Write a program to create a webpage to print values 1 to 5
Write a program to create a webpage to print your city name in red color.
Write a program to print a paragraph with different font and color.
Write an HTML program to display all six heading levels
Write an HTML program for text formatting (bold, italic, subscript, superscript)
Interview Questions & Answers
How to add comments in HTML?
How to add the copyright symbol to a web page?
What is the difference between strong and b tag in HTML?
What are HTML entities?
What is the difference between inline, internal and external CSS?