top of page

PARAGRAPHS

The paragraph element tells your web browser to put any content between the opening paragraph tag <p> and the closing paragraph tag </p> in separate paragraph. 

Let's add another sentence to our code. Here's how the content looks without the use of the paragraph tags:

w/o para demo
w/o para output demo

We may have expected our text to show up in 2 different paragraphs.

But always remember that HTML is for supplying meaning not presentation. 

 

So if we want the 2 lines of text to show up on 2 different paragraphs, we need to use the paragraph element.

Here's how the content looks when we use the paragraph tags:

with para
with para output

LINE BREAKS

The <br> tag adds a line break in your content.

 

Adding the <br> tag to the end of a line of text tells the browser that the following line of text should appear on the next line. 
 

line break demo
line break output

Important things to remember about the <br> tag:

SELF-CLOSING

The <br> tag is a self-closing tag.

U
nlike the body and html tags, it does not need an opening and closing tag. 

This is because there is no content to be nested in a <br> tag.

MOVES TEXT TO NEXT LINE

Web browsers wrap text to the next line only when the current line reaches the right side of the browser. 

When you add a line break in HTML, it simply tells the browser that you want to begin the next line of text on the next line. 

<br> or </br>?

You might see it written as </br>.

This is a remnant of XHTML, a form of HTML based on another markup language called XML.

You can use either <br> or </br> in HTML5. 

You could technically use line breaks as a way to break text into paragraphs. Here's an example:

line break bad use
line break bad use output

Don't do this.

 

The paragraph tags are designed to separate text, use those any time you want the text coming up next to be separated into another paragraph. 

Here's a good way to use line breaks: 

line break poem
line break poem output

Line breaks are best used only when they are a meaningful part of your content like in poetry. 

bottom of page