Tags in HTML


Heading Tags

Every HTML document starts with headings.HTML has six different types of headings ranging from <h1> to <h6> which are mentioned in previous chapters.
    Notations:
  • After defining heading tag browser automatically adds one line before and one line after heading.
  • While designing web pages do not use headings for making text large and bold because serch engine crawler gives first importance to h1 headings then h2 and so on.

Example:

<!DOCTYPE html>
<html>
<body>
<h1>Example as heading.</h1>
<h3>Example as heading.</h3>
<h6>Example as heading.</h6>
</body>
</html>

Output:

Example as heading.

Example as heading.

Example as heading.

Paragraph Tags

Pargraph tag in HTML starts from <p> and ends with </p>.

Example:

<!DOCTYPE html>
<html>
<body>
<p>This is my first paragraph.I like writing pargraphs.</p>
</body>
</html>

Output:

This is my first paragraph.I like writing paragraphs.

Line Break Tag

Line break makes compilers read entire text that is written after it as in next line.Line break tags are assigned by <br> and it never requires ending tag as like many other HTML tags.

Example:

<!DOCTYPE html>
<html>
<body>
<p>
This pargraph is written to show you example of line break tag.<br>Now see the change in output. </p>
</body>
</html>

Output:

This paragraph is written to show you example of line break tag.
Now see the change in output.

    Notation:
  • See that there is no </br> tag in br tag.This tag never requires end tag.

Centering text in HTML(Center tag)

<center> tag can be used to to center any content within page or any table cell.

Example:

<!DOCTYPE html>
<html>
<body>
<p>This is just a paragraph.</p>
<center>
<p>This paragraph is centerd.</p>
</center>
</body>
</html>

Output:

This is just a pargraph.

This paragraph is centerd.

pre tag

pre tag in HTML is used to show the text in excat way as it is typed.

Difference between <pre> tag and <p> tags:

  • <p> tags in HTML counts only one space after each word no matter how many spaces you give in between texts.
  • <pre> tags in HTML displays the text as it is typed.

Example:

<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph tag.
This tag counts only one space,
no matter how many spaces we give.</p>
<pre>This is pre tag.
This tag displays the text in same way as it is typed.</pre>
</body>
</html>

Output:

This is a paragraph tag.This tag counts only one space,no matter how many spaces we give.

This is pre tag.
This tag displays text in same way as it is typed.
    Notations:
  • HTML is not case sensitive.In HTML <h1> and <H1> means same thing.
  • Most HTML elements require end tags but few HTML tags work even though they do not have end tags.But it is recommended to always use end tags.
  • Few HTML elements like <br> tag never require end tags.