Html enter new line
In HTML, there are several ways to create a new line:
- BR Tag: The
<br>
tag is used to insert a line break. It is an empty element, which means it does not have a closing tag.
Example: <br>
- P Tag: The
<p>
tag is used to define a paragraph of text. It is a block-level element, which means it will automatically create a new line before and after the element.
Example: <p>This is a paragraph of text.</p>
- Line Break: You can also use a line break by simply pressing the Enter key twice in your HTML code.
Example:
This is a line of text.
<br>
This is another line of text.
- HTML Entity: You can also use an HTML entity to create a line break. The entity is
.
Example: This is a line of text. This is another line of text.
- CSS: You can also use CSS to create a new line using the
white-space
property.
Example:
<p style="white-space: pre;">This is a line of text.
This is another line of text.</p>
Note: The white-space
property is used to specify the whitespace characters in an element. The pre
value tells the browser to preserve the whitespace characters, including line breaks.