HTML Basic Tags / Elements

As we Learnt What are HTML Elements. Let Get into the basic and commenly used elements.
HTML Elements define the Chracterstics of a content to appear in a html page. The are mainly used in the body section of the html page.
The tags must be enclosed with < > these bracket.
Each element has a tagname with start tag and end tag. But for some tags there is no end tag.
Content is placed between tags is: <tag> Content goes here </tag>

Start Tag

Example

End Tag

<h1>

Heading h1

</h1>

<p>

Paragraph p

</p>

<i>

Italic i

</i>

<br>

Hi I am
Breaked

-

<hr>

Hi I am
Breaked with a line

-

Note: HTML Elements can be represented in small or large case letters like <h1> and <H1>. They are not case sensitive.
Don't Skip the End tag. If so the content may get changed as the characterstics of the unclosed tag will get applied to all elements next to it.

HTML Headings

HTML headings defines the tags <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>.
The headings are bold in text by default.
Each tag has its default font-size but it may differ depending on the browser used.

  • <h1> - 2em (or 32px)
  • <h2> - 1.5em (or 24px)
  • <h3> - 1.17em (or 18.72px)
  • <h4> - 1em (or 16px)
  • <h5> - 0.83em (or 13.28px)
  • <h6> - 0.67em (or 10.72px)

Observe the example to know the difference

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Heading Example</title>
  </head>
  <body>
    <h1>Your Heading 1</h1>
    <h2>Your Heading 2</h2>
    <h3>Your Heading 3</h3>
    <h4>Your Heading 4</h4>
    <h5>Your Heading 5</h5>
    <h6>Your Heading 6</h6>
  </body>
</html>


HTML Paragraphs

HTML paragraphs are defined with only <p> tag.
The <p> tag has a default font size is around 16 pixels (1em).

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Paragraph Example</title>
  </head>
  <body>
    <p>This is a paragraph text</p>
  </body>
</html>

HTML Links - a (Anchor) Tag

HTML links are defined with the <a> tag.
href attribute isued to define a link with in a tag.
<a> tag is also called the anchor tag.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Link - anchor tag Example</title>
  </head>
  <body>
    <a href="https://www.bmreducation.com/">This is a Link</a>
  </body>
</html>

Note: Get to know more about HTML Links

HTML line break tags

HTML Line break tags are used to break a line in a text and start a new line without starting a new paragraph.
The <br> tag defines a break of the line and start a new line.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Link Break - br tag Example</title>
  </head>
  <body>
    <p>Hi I am <br> Breaked</p>
  </body>
</html>

The <hr> tag seperates a content with a horizontal line.


HTML <pre> Element

The HTML <pre> element defines preformatted text, which preserves white space and line breaks within the text.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>pre tag Example</title>
  </head>
  <body>
    <pre>
  BMR EDUCATION
  is offering
   HTML Course
   </pre>
  </body>
</html>

HTML Images

HTML images are defined with the <img> tag.
src attribute is ued to define a link with in a tag.
alt attribute is used to give the description of the image.


Example

<!DOCTYPE html>
<html>
  <head>
    <title>img tag Example</title>
  </head>
  <body>
    <img src="/images/Logo.ico" alt="BMR LOGO Image" width="150" height="150" >
  </body>
</html>

Get to know more about HTML Images


Quick Recap - Topics Covered

Basic Tag Structure
HTML Headings and Paragraph
HTML Links
HTML Line Breaks
HTML Pre and Img tags

Practice With Examples in Compilers

The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compile or Try on own Now


Example js

Example 1 Example 2 Example 3 Example 4 Example 5


Quiz


FEEDBACK