the <caption> html tagWebsites by Mark - 7 Woodrush gardens, Carterton, Oxfordshire. OX18 1JE

the <caption> html tag
the <caption> html tag

The <caption> html tag

Overview

The <caption> HTML tag is used to specify a title for a HTML Table. It can only be used once per table and the <caption> tag must appear immediately after the <table> tag. It works equally as well in table based layouts as well as CSS based ones. When text is put between the opening and closing <caption> tag it is displayed as a table caption text.

Basic Usage

<caption>Some table caption text in here</caption>
Any text between the opening and closing tag will be displayed as table caption text.

Advance Usage

It is possible to style and add functionality to the <caption> tag, this is done by adding an attribute to after the caption in the opening <caption> tag
Attributes allowed for the <caption>tag include :-class, dir, id, lang, style and title.
In most cases class and id are used and its basic usage is shown below
<caption id=”header”>Some table caption text</caption>
With all attributes there is a space after the initial caption then the attribute name, then an equal’s sign and the identifier of the attribute in double quotes.
Both id and class attributes refer to CSS styling of the element and is either stored in the <head> of the webpage on in an external file.
With id this usually refers to a single instance on a page where as class usually refers to a repeating element on a page, it is for this reason for the <caption> tag may use either the id or class as an atribute.
The attribute style allows you to include css style information for a single <caption> tag.
The dir attribute allows for left reading and right reading text, lang allows you to specify a language for the tag and title allows you to include extra information for a tag.
It is possible to attach scripts to tags, as well adding functionality to a webpage, these scripts tend to be written in Javascript and therefore outside the scope of this document

Examples

<caption>Some table caption text</caption> – basic usage example.
<caption id=”header>Some table caption text</caption> – table caption text which is styled by the id header.
<caption class=”headerclass”> Some table caption text </caption> – table caption text which is styled by the class headerclass.
<caption id =”header” class=”headerclass”> Some table caption text </caption> – table caption text which is styled by the class headerclass and the id header.
<caption style="color:#F00">Some table caption text</caption> – table caption text which has a custom colour of red.
<caption dir="rtl">Some table caption text</caption> – table caption text where the text reads from right to left.
<caption lang="uk">Some table caption text</caption> – table caption text where the language has been tagged as UK.
<caption title="ptitle">Some table caption text</caption> – table caption text where the tag has been titled ptitle.

Final Thoughts

Touching on just the surface of the <caption> HTML tag it is easy to see how versatile it is. To take full advantage of it an understanding of CSS is an advantage.

Website for £99

Offers

 

Categories

 

Our blog

Some random stories from our blog.

When our space became Myspace

With what we can do online exploding exponentially on a daily basis, it’s often the case that Social Networks like Myspace offer a useful way to wall your online world. With Myspace now offering a dedicated online games platform, how long before we get our first truly interactive broadcast channel, and will the first past the post end such giants as Facebook, You Tube or even Google itself. All seeing Google Google has become the centre of most people internet universe, its quick loading time and accurate results has always been popular with users and with its ever evolving services it’s difficult to see how Google will ever lose its dominate position. With the EU constantly fining Microsoft for uncompetitive practises would it is possible in the future for Google to come to the same fate. With Governments around the worlds relentless push to regulate and sanitise the net, it…

Why not ask for a free quote?

The <h3> html tag

Internet, Google and the price of freedom

The <h5> html tag

© 2011 Websites by Mark. Do not reproduce any part of with website without permission.
Email : mark@websitesbymark.co.uk - Phone : 07716 447228 / 01993 221500
Postal Address : 7 Woodrush Gardens, Carterton, Oxfordshire. OX18 1JE