Forum Moderators: open

Message Too Old, No Replies

what's the rule in using <head>

         

KathyJones

3:07 am on Apr 18, 2003 (gmt 0)

10+ Year Member



What's the problem with doing something like this (code A)inside of a table which inside of a body like (code B)?
I got an error message saying head "head" is not allowed at where it is in (code A). And how can I fix it? Can <head> be used only once in each <html> or what is the rule?
------------------------------------------------------------------------------------
(code A):

<tr>
<td><center>head</center></td>
<td>contains info about the document</td>
<td>
<head>
<title>Title goes here</title>
</head>
</td>
</tr>
-------------------------------------------------------------------------------------
(Code B):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
...... (code A) goes inside of a table here..
</body>

rainborick

3:13 am on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That's just the way the standard is, Kathy. The <head></head> section, and all of the elements that belong inside it, have to be placed ahead of the <body> tag. This section is for information on the structure and details of the page, as opposed to the actual content of the page which belongs between the <body></body> tags. Now, most browsers will still try their best to render your page even if you have the <head> section where it doesn't belong and even if you have duplicate tags all over the place, but you have to stick with (B) in order to be standards compliant and have any certainty that users will actually see the page the way you intended.

grahamstewart

3:18 am on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All your html documents (in html4 transitional) should have the basic form of...

[pre][1]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
...head tags like title, meta, link
</head>
<body>
... your actual site..
</body>
</html>
[/1][/pre]

The basic idea is that the head section contains information that describes the page, so search engines can (in theory), just download the head of your page to find out everything about it.

Some tags can only be used in head. <title>, <meta> and <link> are examples of this.

grahamstewart

3:24 am on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To give your table a title you can use the <caption> tag like this...


<table>
<caption>your caption text</caption>
<tr>
<td>head</td>
<td>contains info about the document</td>
</tr>
</table>

g1smd

6:54 pm on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There are other consideratons, as well as those above, for what goes in the <head> section. Code on my pages always begins with:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title> Your Title Here </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-gb">
<meta name="Keywords" content=" your, keyword, list, here ">
<meta name="Description" content=" Your Description Here. ">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<meta http-equiv="imagetoolbar" content="no">

</head>

Of the en-gb part, the first two letters come from the code list in ISO 639 and the last two letters come from the code list in ISO 3166.

See also ISO 4217 for codes for representing currency, and then ISO 8601 for formats for date and time.

Code within the page:

I use: <a href="somepage.html" title="some text here"></a> for links.

I use <img src="somefile.png" alt="some text"> for images.

Headings are done with <hx></hx> tags, properly used from <h1></h1> downwards.

grahamstewart

2:23 am on Apr 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



g1smd: I'm sure I've probably said this to you before, but you must use the full doctype for the browser to render your page in standards mode. The short doctype you are using puts the browser into 'quirks' mode - which mean the page will render differently on different browsers.