HTML Paragraph

In HTML, paragraphs are defined using the <p> tag. This is perhaps the most basic tag and the first one you will need to publish while creating a new web document. Here is an example of a paragraph tag.

<p> This is a paragraph. </p>

The built in style sheets of a browser will automatically create spaces between paragraphs although these default settings can be overridden using cascading sheet styles. Note that even if you forgot the closing tag of a paragraph tag, most browsers will display the code correctly. However, it is recommendable for developers to include both start and end tags because of browser compatibility issues.

To initiate a line break without necessarily beginning a new paragraph use the <br> element. This is one of the void elements that do not require an end tag because they are meant to enhance the appearance of a document, but are not containers for data. Below is an example of a code snippet that uses the <br> element to create a line break.

<p> This is a paragraph <br> with line break. </p>

Remember that it is not advisable to use empty paragraph tag <p> </P> as a break for creating a new line. At times, this might be ignored by the browser. For easier readability of your code in future it is important to include comments. These are lines in your code that explain what you intend to accomplish with it. In HTML, a comment is initiated by <!- – and ends with – ->. To create extra space by inserting &nsbp; or the <br> element to initiate a line break like in the examples shown below.

Share.

Terry White is a professional technical writer, WordPress developer, Web Designer, Software Engineer, and Blogger. He strives for pixel-perfect design, clean robust code, and a user-friendly interface. If you have a project in mind and like his work, feel free to contact him

Comments are closed.