HTML Elements

Basic HTML Elements

Paragraph Tag

The <p> tag is used to create a new paragraph. <p> tag is opening element for paragraph and </p> is closing element. All the Text of paragraph should be placed in between <p> and </p> tag as shown below in the example:

Example

<p>This first paragraph of text.</p>
<p>This is a second paragraph of text.</p>
<p>This is a third paragraph of text.</p>

This will produce following result:

Here is a first paragraph of text.
Here is a second paragraph of text.
Here is a third paragraph of text.

You can also use The Align Attribute with <p> element. but this is not work HTML 5

For example

<p align="left|right|center|justify">Text </p>

You can also use the Title, ID, Style attribute with Heading element. See the Attribute in HTML Tutorial. For example

<p style="color:blue;text-align:center">a

This is simple text for paragraph

</p>

Line Break Tag

<br /> tag is used for line break. When placed an <br /> the any thing after this tag will start on next line. This tag is an empty element. An empty tag do not need opening and closing tags. But in XHTML we put forward slash <br /> with a space.

Example
<p>

Hello this is first line in this paragraph<br />
now we are on next line.<br />
Thanks <br />
Nida Malik

 </p>

In above example we have a single paragraph but with three lines.

Hello this is first line in this paragraph
now we are on next line.
Thanks
Nida Malik

<Center> Element

<center> tag is used to placed the text in the center of the page or in a table cell.

Example
<p>This text is not in the center.</p>
<center>
<p>This text is in the center.</p>
</center>

<Pre> Element

If you want that your text display in the browser in exact format as you write then in HTML you can use <pre> element. Any text between the opening <pre> tag and the closing </pre> tag will be display as well as.

Example
<pre>

function testFunction( strText ){
alert (strText)
}

</pre>

Although this is a script but due to use of <pre> element before this script it will show same as written:

Try using same code without keeping it inside <pre>...</pre> tags

HTML <b> Tag

Any text between <b> and </b> tag is appear bold in the browser.<b> tag not only add little more ink to text also get some extra importance.

<p>

My Name is <b> Nida Malik </b>

HTML <strong> Tag

The <strong> tag also make bold the text and defines important of the text.

Difference Between <B> and < Strong>

There is some difference between <B> and < Strong> tag. Physically they are same effect but logically bold is nothing on the other hand logically <strong> have some extra meaning. When you add some more ink to text its become bold but its nothing for a blind person.This is same as when you increase the font size with <font> tag but when you use <H1> which not only increase the font size physically but also special meaning for search engine .