You are on | Tutorials / HTML / Tags in HTML
Chapter 1: HTML & web pages


Internet and world wide web
Tags in HTML
URLs in HTML
Planning and designing a website
Structure of the HTML document
Setting Document background

Chapter 2: Working with Text
Chapter 3: Working with images
Chapter 4: Audio and videos
Chapter 5: Hyperlinks
Chapter 6: Tables
Chapter 7: Forms
Chapter 8: Frames
Chapter 9: CSS
Chapter 10: HTML entities
Chapter 11: HTML colors

 

HTML Tags


An HTML document is a text file that contains only text. When a browser opens an HTML file, it looks for HTML commands in the text and uses them to display text, images, or create links to other web pages.

Since HTML documents are just text files, they can be written in a simple text editor. In these tutorials we will use Notepad to create HTML documents.

HTML tags:

HTML commands are called markup tags (Tags for short). Each tag is written between angular brackets < and > ( Less than and more than signs ).

HTML tags are written according to a certain syntax show below
  1. The markup tag is written within angle brackets (< and >).
  2. Most tags consist of a starting tag and ending tag. The text that the tag controls is written within these two tags.
  3. Ending tags are similar to starting tags. The use same command words. However, a forward slash (/) is written immediately before the ending tag name.

The following is an example of a paragraph tag. This tag displays the text " Hello world " in a paragraph.

<p> Hello World </p>

 

Tag attributes:


An HTML tag may have one or more attributes. An attribute is used to specify a property of the tag.

Attributes are included in the starting tag, between the tag name and the final bracket (>).

Attributes have values. For example the ALIGN attribute have the values of left, right or centre. Values are enclosed in quotation marks ( "" ) - Straight quotes.

For example, the following tag displays the text HELLO WORLD as a centre-aligned paragraph.

 

<p align="center">Hello world </p>

 

Nested Tags:


A tag contained within another tag is called the nested tag.

For example, the <b> tag is used to make text bold. This tag may be written within a paragraph tag:

<p>Hello <b>world </b> </p>

 

The following rules are followed while writing the nested tags.

  1. The tags that affect an entire paragraph can contain tags that affect individual words or letters within that paragraph.
  2. The order in which nested tags are written is important. Whenever an ending tag is used it should correspond to the last unclosed tag.

 

The following HTML code displays World in bold and italic. Notice the order of the ending and starting tags.

<p>Hello <i><b>world </b></i> </p>

 
Case sensitivity:

HTML code can be written in either lowercase, uppercase or a combination of the two. It is case insensitive.

•  Usually tags and attributes are usually written in uppercase to make them different from the text that is to be displayed.

•  XHTML, the next version of HTML, uses lowercase and to maintain the compatibility with XHTML, tags and attributes should be written in lowercase.

 

Block tags and inline tags:


Some tags, such as paragraph tag <p>, include line breaks. When a closing paragraph tag is used, there is no need to press Enter to begin a new paragraph with a new line. These tags treat the contents within them as one unit or block. These are called block level tags. Some commonly used block level tags are <p>, <h1>, <br>, <ul> and <table>.

 

Other tags are called inline tags. These tags affect only a few letters or words and they don't contain a line break within the closing tag.

Bold < B >, Italics < I > and font <font> are examples of inline tags.