Pages

Friday, May 9, 2014

HTML Paragraph



HTML documents are divided into paragraphs. Any text containing more than a few lines (or sometimes even more) should exist inside of a paragraph tag <p>. This tag is reserved specifically for blocks of text, such as those you would expect to find inside your favorite novel. The <p> element offers a way to structure your text.


Each paragraph of text should go in between an opening <p> and closing </p> tag as shown below in the example. Well written HTML documents can gain popularity through Search Engine Optimization and careful coding of your HTML elements.
Precision is important when writing your code. Web spiders are a little forgiving when it comes to malformed HTML elements. For best results, do your best to ensure your code is complete and accurately constructed.


Create Paragraph - The <p> Element:

Paragraphs are defined with the <p> tag.

Example: 1

<html>
<head>
<title>My web page</title>
</head>
<body>
<p>Here is a paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>

This will produce following result:
Here is a paragraph of text.
Here is a second paragraph of text.
Here is a third paragraph of text.     

 

Example: 2

<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html
This will produce following result:
This is a paragraph.
This is a paragraph.
This is a paragraph.


Example:3

<!DOCTYPE html>
<html>
<body>
<p>This is First Paragraph.
A paragraph is a self contained unit of a discourse in
writing dealing with a particular point or idea. A paragraph
consists of one or more sentences. The start of a paragraph is
indicated by beginning on a new line.</p>
<p>This is second Paragraph.
A paragraph is a self contained unit of a discourse in
writing dealing with a particular point or idea. A paragraph
Consists of one or more sentences. The start of a paragraph is
indicated by beginning on a new line.</p>
<p>This is Third Paragraph.
A paragraph is a self contained unit of a discourse in
writing dealing with a particular point or idea. A paragraph
consists of one or more sentences. The start of a paragraph is
indicated by beginning on a new line.</p>
</body>
</html

This will produce following result:
This is First Paragraph. A paragraph is a self contained unit of a discourse in writing dealing with a particular point or idea. A paragraph consists of one or more sentences. The start of a paragraph is indicated by beginning on a new line.
This is second Paragraph. A paragraph is a self contained unit of a discourse in writing dealing with a particular point or idea. A paragraph consists of one or more sentences. The start of a paragraph is indicated by beginning on a new line.
This is Third Paragraph. A paragraph is a self contained unit of a discourse in writing dealing with a particular point or idea. A paragraph consists of one or more sentences. The start of a paragraph is indicated by beginning on a new line.

Note: Browsers automatically add an empty line before and after a paragraph.



You can use align attribute to align your paragraphs:
<p align="left">This is left aligned.</p>
<p align="center">This is center aligned.</p>
<p align="right">This is right aligned.</p>
<p align="justify">This is jutified. This works when you have multiple lines in your paragraph and you want to justfy all the lines so that they can look more nice.</p>




 

Don't Forget the End Tag:

Most browsers will display HTML correctly even if you forget the end tag:
Example:

<p> Here is a paragraph of text
<p> Here is a second paragraph of text
<p> Here is a third paragraph of text
The example above will work in most browsers, but don't rely on it. Forgetting the end tag can produce unexpected results or errors.
Note: Future version of HTML will not allow you to skip end tags.



HTML Line Breaks:

Use the <br> tag if you want a line break (a new line) without starting a new paragraph:
Example: Line break source code:

<!DOCTYPE html>
<html>
<body>
<p>This is a<br> paragraph <br> with line breaks</p>
</body>
</html>


NOTE: The <br> element is an empty HTML element. It has no end tag

This will produce following result:
This is
a paragraph
with line breaks



HTML Output - Useful Tips:

You cannot be sure how HTML will be displayed. Large or small screens and resized windows will create different results.
With HTML, you cannot change the output by adding extra spaces or extra lines in your HTML code.
The browser will remove extra spaces and extra lines when the page is displayed. Any number of lines counts as one line, and any number of spaces count as one space.



&nbsp command in Paragraph Element:
&nbsp means ampersand next before space.
To increase more space in paragraph use this command.
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>&nbsp
<p>This is a paragraph.</p>&nbsp
<p>This is a paragraph.</p>
</body>
</html

This will produce following result:
This is a paragraph.

This is a paragraph.

This is a paragraph.


No comments:

Post a Comment