HTML <h...> tagwritten Sept 2000 being revised May 2006 |
<h1>h1 Header</h1>
h1 Headerh2 Headerh3 Headerh4 Headerh5 Headerh6 Header | <font size=+1><h1>h1 Header</h1></font>
h1 Headerh2 Headerh3 Headerh4 Headerh5 Headerh6 Header |
<h1><font size=+1>h1 Header</font></h1>
h1 Headerh2 Headerh3 Headerh4 Headerh5 Headerh6 Header | <h1 style='font-size larger;' >h1 Header</h1>
h1 Headerh2 Headerh3 Headerh4 Headerh5 Headerh6 Header |
OK, so that did not do what one might have expected. If you want to dress up your header in any way you should use the style attributes with the CSS specifications suitable for a heading. CSS offers border specifications (border-width , border-style, border-color), and also background specifications (background) and text colour (color).
Here is a first simple use of 'style':
<h1 style='border-width: 4;'>h1 Header</h1>
<h1 style='border-width: 4; border-style: double;'>h1 Header</h1>
<h1 style='width: 50%; border-width: 4; border-style: double;'>h1 Header</h1>
<h1 style='font-family: verdana, sans-serif; font-style: italic;
color: red; text-decoration: underline;'>h1 Header</h1>
h1 Header |
<div style='text-align: left'>
<table cellspacing=0 cellpadding=0 ><tr>
<td><p style='border-width: 4; border-color: red; border-style: ridge;
font-size: x-large; font-weight: bold; padding: 2 8 2 8; color: green'>h1 Header</p>
</td></tr></table>
</div>
Here is a centre-aligned version, but with a background colour added. The IE version is correct in this case, the background is defined to cover the area of the border, padding and content, excluding only the transparent margin. Netscape 4.7 applies the background only to the padding and content area and even then leaves a small gap. Netscape 6 corrects this error.
h1 Header |
<div style='text-align: center'>
<table cellspacing=0 cellpadding=0><tr>
<td><p style='border-width: 6; border-color: red; border-style: double;
font-size: x-large; font-weight: bold; padding: 2 8 2 8; color: blue;
background-color: yellow; ' >h1 Header</p>
</td></tr></table>
</div>
Here is a right-aligned heading with an image background:
h1 Header |
<div style='text-align: right'>
<table cellspacing=0 cellpadding=0><tr>
<td><p style='border-width: 8; border-color: red; border-style: groove;
font-size: x-large; font-weight: bold; padding: 2 8 2 8;
background: url(Cottcndy.jpg) pink; '>h1 Header</p></td></tr></table>
</div>
Shadow for headings is a nice effect and it is part of the CSS2 specification, but commonly used browsers dont implement it. Since even Netscape 6 is not implementing this attribute, it is safe to assume that this effect will have to be acheived some other way for a while yet. It can be fudged to some extent by using absolute positioning within a box which has relative position.
<div style='position: relative'>
<div style='position: absolute; top: 3; left: 3; font-size: x-large;
font-weight: bold; color: silver;'>Shadow Heading</div>
<div style='position: absolute; top: 0; left: 0; font-size: x-large;
font-weight: bold; '>Shadow Heading</div>
</div>
This makes use of the position attribute which was added as an extension to CSS1, and which was developed in CSS2. When a tag is given a position attribute it is considered to be a positioned block. Blocks with absolute positions are positioined with respect to their immediately enclosing block which has a position attribute, or the whole page by default. IE has implemented this to some extent but does not properly manage the space used. Netscape 4.7x has a bug in its handling of positioned blocks which means that seperate uses of this code wont work. Netscape 6 does work.
In this example the position attributes for the black heading are the default attributes. You might think you can leave them out, but then they get processed first and the 'silver shadow' ends up on top. This fudge of text-shadow does not provide for the blur effect which is described in CSS2.
One might expect that using <div style='position: relative; text-align: center'> would center the shadow heading, but not so. To do this reliably it must be set inside a centered table, just as for the border headings shown above.