HTML Paragraphs are used to neatly separate content on your page. Update your HTML file with the code below. Save and refresh your browser.
<!DOCTYPE html> <html> <head> <title>This is my page title.</title> </head> <body> My first line of text My second line of text </body> </html>
You will notice that even though you have 2 lines of text in your file, they both show on the same line in your browser. This is because web browsers do not render new lines or even spaces. You will need to use HTML elements to do this.
To accomplish this, we will use our <p> tag. Below is the code to have 2 lines of text.
<!DOCTYPE html> <html> <head> <title>This is my page title.</title> </head> <body> <p>My first line of text</p> <p>My second line of text</p> </body> </html>
The <p> stands for Paragraph. The browser will render each paragraph tag as a new paragraph and therefore you'll now have your text on two separate lines.
Add this new code to your file, save and refresh. You should now see your text on two lines.
Some commonly used tags within paragraphs are the <em> and <strong> tags. These tags are used to emphasize pieces of text. Below is an example.
<p> You're officially <em>learning</em> HTML! <strong>Careful:</strong> Don't get too excited.. </p>
The line break or <br> tag is another way to separate lines of text.
<p> This is my first line of text. <br> This is my second line of text. </p>
The line break tag is a good example of a tag that does not need a closing tag. This is because it will never have content inside.
This website and it's tutorials are only made possible with your support. Support money goes towards keeping our servers online.
Spread the word! Let people know about our tutorials by placing links on blogs, websites, forums and other places.
Copyright 2019 Step By Step HTML. All Rights reserved.