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

the <center> html tag
the <center> html tag

The <center> html tag

Overview

By default body text in a HTML document is aligned left, by using the <center> HTML tag you can make the text appeared centered within its surrounding tag. It is a widely used tags in HTML today. It works equally as well in table based layouts as well as CSS based ones. It was often used in the past to centre the content of <div> tags, but this is now usually dealt with purely in CSS. As with all older HTML tags it can be used in situations where consistancy between browsers is difficalt to acheive in other ways. When text is put between the opening and closing <center> tag it is displayed as a center text.

Basic Usage

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

Advance Usage

It is possible to style and add functionality to the <center> tag, this is done by adding an attribute to after the p in the opening <center> tag
Attributes allowed for the <center>tag include :-class, dir, id, lang, style and title.
In most cases class and id are used and its basic usage is shown below
<center id=”header”>Some center text</center>
With all attributes there is a space after the initial p 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 <center> tag may use either the id or class as an atribute.
The attribute style allows you to include css style information for a single <center> 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

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

Final Thoughts

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

Our blog

Some random stories from our blog.

Keyword use in bold body text

Overview Search engines like Google use the text visible on the screen as one of the factors used to determine how important a page is to a certain search phrase. Bold body text as expected plays a role in this ranking. In short if a section of text is tagged as bold or strong, search engines like Google assume this text is a more important part of the page. History of Keyword use in bold body text In the first versions of HTML the <b> tag was used to determine text which should be displayed as being bold. With the evolution of HTML, a new tag was created to really replace the <b> tag. With regards to the website visitor both tag visually do the same thing, but on a higher level using the <strong> tag is more consistent with the aims of the tag. Although both can still be…

The <h2> html tag

Overview In HTML h tags stand for heading and this is split into 6 different h tags (h1, h2, h3, h4, h5 and h6). The <h2> tag itself is considered to be the main repeating heading for a webpage. By default it is displayed much larger than the body text but smaller than the main <h1> header. As with all h tags it is considered important for SEO.When text is put between the opening and closing <h2> tag it is displayed as a large heading. Unlike <h1> a <h2> tag can be used multiple times on a webpage as its job is to be the heading for a web pages main sub topics. Basic Usage <h2>Large header text</h2> Any text between the opening and closing tag will be displayed as a large heading. Advance Usage It is possible to style and add functionality to the <h2> tag, this is done…

The <cite> html tag

Overview The <cite> HTML tag is known as a phrase tag, it is mainly used to style text. By default it displays text as italic which is ideal for showing a quotation or citation. It works equally as well in table based layouts as well as CSS based ones. As with all phrase based HTML tags it can be used in situations where consistancy between browsers is difficalt to acheive in other ways. When text is put between the opening and closing <cite> tag it is displayed as a citation text. Basic Usage <cite>Some citation text in here</cite> Any text between the opening and closing tag will be displayed as citation text. Advance Usage It is possible to style and add functionality to the <cite> tag, this is done by adding an attribute to after the cite in the opening <cite> tag Attributes allowed for the <cite>tag include :-class, dir,…

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…

Im going on a browser hunt, Im not scared

Google recently made the decision to end support for Microsoft Internet Explorer version 6 for its online office based applications. What wasn’t shouted quite so loudly was the ending of support for Firefox 2 and Chrome 3. In an online world where technologies evolve on a daily basis, should we worry about when old technology standards die or should we embrace in a lemming like state anything Google or Microsoft choose to throw at us? It’s alive With the invention of the internet as we know it today it wouldn’t be long before tools to view this brave new world became available. The pioneers were Microsoft and Netscape, but these were not the only ones, but due to Microsoft bundling its browser with its operating system Windows, it quickly became the browser of convenience for all but the very determined. But Microsoft was never going to have its own way…

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