Hello, world!

Display HTML

You will learn how the browser interprets the HTML code and displays it i.e. the browser will ignore any number of spaces and any number of new lines. This part of the html tutorial is about display html.


HTML code space

<!DOCTYPE html>
<html>
<body>
 
<p>
Browsers will
ignore      blank spaces
and new lines  inserted
into source     code.
</p>
 
</body>
</html>

Output HTML code space

Browsers will ignore blank spaces and new lines inserted into source code.


Line Break Tag HTML

The line break tag <br> is applied when you need a line break or a new line without beginning a new paragraph, therefore  anything succeeding the break tag begins from the next line. There is no content contained in breaking lines, hence this element has no opening and closing tag.

HTML code Line Break Tag

<!DOCTYPE html>
<html>
<head>
<title> How to do Line Break</title>
</head>
<body>
<p>Hi John,<br />
You've done a great job!<br />
Thank you,<br />
Joe</p>
</body>
</html>

Output HTML code Line Break Tag

Hi John,
You've done a great job!
Thank you,
Joe


Preserve <pre> Formatting HTML

The tag <pre> indicates preformatted text. This includes line breaks without the application of the <br> tag.
Preformatted elements in HTML are presented with text in a fixed width font commonly Courier and it preserves the existing formatting system of the source document.
In addition, the <pre> element preserves both spaces and line breaks as well.

HTML code Preserve <pre> Formatting

<!DOCTYPE html>
<html>
<body>
<pre>
Preformatted elements in HTML are presented with text in a fixed width font commonly Courier and it preserves the existing formatting system of the source document.
</pre>
</body>
</html>

Output HTML code Preserve <pre> Formatting

Preformatted elements in HTML are presented with text in a fixed width font commonly Courier and it preserves the existing formatting system of the source document.

<center> tag HTML

Applying the <center> tag allows you to center text or any table cell in HTML.
Place the text within <center></center> tags.

HTML code <center> tag

<!DOCTYPE html>
<html>
<head>
<title>This is a centered paragraph.</title>
</head>
<body>
<center>
<p>This is a centered paragraph.</p>
</center>
</body>
</html>
 

Output HTML code <center> tag

This is a centered paragraph.


Horizontal Lines HTML

Applying the horizontal rule <HR> tag generates a horizontal line the width of the browser window. Horizontal lines are applied to separate major sections of a document.

HTML code Horizontal Lines

<!DOCTYPE html>
<html>
<head>
<title>How to make Horizontal Line</title>
</head>
<body>
<hr />
<p>This text is placed between the two horizontal lines</p>
<hr />
</body>
</html>
 

Output HTML code Horizontal Lines


This text is placed between the two horizontal lines



Nonbreaking Spaces HTML

Applying the &nbsp; entity allows you to force the browser not to break the line among words or web page elements.
Apply a nonbreaking space entity &nbsp; rather than a normal space to let the browser not to break a text.

HTML code Nonbreaking Spaces

<!DOCTYPE html>
<html>
<head>
<title>How to make Nonbreaking Spaces </title>
</head>
<body>
<p>Example of "Nonbreaking&nbsp;Spaces"</p>
</body>
 

Output HTML code Nonbreaking Spaces

Example of "Nonbreaking Spaces"