WebDevelopersNotes logo

home-icon Home / HTML / HTML commands – Format of a tag

HTML commands – Format of a tag

HTML commands - Format of a tag

The HTML files are plain ASCII text files that are displayed by the browser in whatever form you have specified. TAGS control the layout and formatting of the elements in HTML. These tags (and there are quite a few of them) are the building blocks of HTML.

The basic syntax of a tag:

<TAG-NAME {ATTRIBUTE1{=”VALUE1″ …}}>{Some text that is affected}</TAG-NAME>

The above notation might seem confusing to you at first; let’s break it down:

  • Each tag consists of the name of the tag surrounded by the less-than ‘<‘ and greater-than ‘>’ signs.
  • Tag names cannot contain spaces. Thus, <HT ML> is wrong.
  • Most (not all) tags require an end tag that differs with the opening tag by a slash ‘/’. Thus if the opening tag is <TITLE> the end tag will be </TITLE>. Note: XML requires all tags to have an ending tag, so if you are working on XML, be sure to place closing tags for everything.
  • Attributes control the different properties of the tag. Each tag has some default values for its attributes. To modify these, you have to set the attributes to the new values. For example, if you want to draw a horizontal rule across the page you can use the <HR> tag. This puts a shaded rule across the page.
    The <HR> tag without any attributes, draws a full length (100%) rule across the page. To decrease its length to half its value, you should specify “50%” value to the WIDTH attribute. The attibute-value pair is written inside the starting tag. Thus, with <HR width=”50%”>, we’ll get a shorter horizontal rule
    A tag can have many attributes and each attribute may have many values (some attributes have no value). More than one attribute can be placed in a tag.
  • Tags usually surround some text. This text is displayed based on the instructions contained in the tag and its attributes.
    A simple example is the Bold (<B> and </B>) tag. When these tags are placed surrounding some text, it becomes bold as:
    This is bold text
    (<B>This is bold text</B>)
  • Browsers ignore unknown tags and attributes. For example, <BOOK> does not have any meaning to the browser and is ignored. (Note: There are some non-standard tags, which are interpreted only by a particular browser and ignored by others. Such tags are browser specific.)

Sponsored Links

Your comments
Star icon IMPORTANT Have a question / problem? Click here to ask an expert.

If it's on the Internet, it must be true.

Sponsored Links


How do I view a deleted web page?
Is there a way to view a deleted web page - one that is no longer available? Yes there is and the solution is quite simple. [more...]


Ever since acquisition, Amazon.com has been using IMDb.com as a platform to advertise their products, especially, DVDs and videotapes. [more...]

We use cookies to give you the best possible website experience. By using WebDevelopersNotes.com, you agree to our Privacy Policy