Write a program to create a webpage to print values 1 to 5

Description: Create a web page that prints the values 1 to 5. Each value should be on a new line.

Hint:

  • Use one <p> tag for each value, or the <br> tag for a line break.

HTML program to print 1 to 5

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Numbers</title>
</head>
<body>
  <p>1</p>
  <p>2</p>
  <p>3</p>
  <p>4</p>
  <p>5</p>
</body>
</html>

Output in the browser:

Output in the browser

1

2

3

4

5

How it works

  • Every <p> tag is a paragraph, and the browser puts each paragraph on a new line.
  • You can also write 1<br>2<br>3<br>4<br>5 inside one paragraph. The <br> tag gives a line break.
  • If you want a numbered list, use <ol>. See HTML Lists.

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?