Home » ASP.NET Basics » Appendix C
C

Some common HTML tags

Functions of different html tags

Tag

Use

 <html> ... </html>

Defines the HTML Page

 <head> ... </head>

Defines the header section of the page.

 <body> ... </body>

Defines the body section of the page.

 <title> ... </title>

Displays the title of the page in the title bar of the browser. Used inside the header section.

 <h1> ... </h1>

Displays the specified text as a heading. There are six levels of headings. <h1>, <h2>, <h3>, <h4>, <h5> and <h6>.

 <p> ... </p>

Used for defining a paragraph.

 <br>

Used for defining a line break.

 <img> ... </img>

Used for adding an image to the page

 <a> ... </a>

Used for specifying a hyper link.

 <table> ... </table> <tr> ... </tr> <td> ... </td>
 <table>

tag is used to create a table. Inside it, the

 <tr>
tags define table rows. Each
 <tr>
tag can contain one or more
 <td>
tags which define the cells in a row.

Tables are used for displaying tabular data. However, many developers use it for dividing a page into sections so that different elements can be placed in these sections.

It is recommended to use the

 <div> 
tag instead of tables for creating sections in a page.

 <div> ... </div>

Used for creating blocks (sections) in a page. These sections can be placed at different positions on the page.

 <form> ... </form>

Defines HTML form. Various controls for user interaction like text box and buttons are placed inside the form.

The above list shows only some of the tags available in HTML. The tags are used in pairs; an opening tag should have a closing tag. However, some tags can be used by itself without closing them like the <br> or the <hr> tags.

We can also specify attributes with the tags. Attributes provide further information on how to display the element in a tag. Using the attributes, we can provide background and foreground colors, font styles, width, height, and position of the elements. For example, the following <body> tag will display the page with a black background:

 <body bgcolor = "000000"> . . . </body>

Note that the different versions of HTML may also implement the tags and attributes differently. Similarly, the XHTML enforces some strict rules on using tags and attributes.