![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
Regular Coder ![]() Join Date: Jun 2003
Location: California
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
I am pretty good with HTML, and am currently teaching myself VBscript. I noticed in this example that the head and title tags were missing but yet i got the same effect...no problem occured.
<html> <body> <script type="text/vbscript"> document.write("Hello from VBScript!") </script> </body> </html> I know what the head tag is for, but if there is no code between the <head></head> tags, can it be left out, or is it good practice to include it anyway? |
|
|
|
|
|
PM User | #2 |
|
The Infractionator-inator ![]() ![]() Join Date: May 2002
Location: Marion, IA USA
Posts: 5,605
Thanks: 3
Thanked 21 Times in 21 Posts
![]() |
You should always include it. The basic set of tags that should be in every web page should include:
PHP Code:
__________________
Spookster CodingForums Tyrant All Hail Spookster Where do you want to go today? Microso... errr Wrong!!! Make the switch Ubuntu Linux |
|
|
|
|
|
PM User | #3 |
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
Well, you may not leave it out. Html, head and body tags are required in an HTML document. It's just that the html, body and head opening tags are optional, so the browser should "fill them in" for you if they're absent.
Here's the smallest html document possible Edit: well, unless you take into account the various SGML specials that browsers today don't support :Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <title></title> <p> Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title></title> </head> <body> <p></p> </body> </html>
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards Last edited by liorean; 05-02-2004 at 10:37 PM.. |
|
|
|
|
|
PM User | #4 |
|
The Infractionator-inator ![]() ![]() Join Date: May 2002
Location: Marion, IA USA
Posts: 5,605
Thanks: 3
Thanked 21 Times in 21 Posts
![]() |
I don't know if I would use the term optional. That's saying it is okay to leave them out.
Those tags are all apart of the structure of a web page. Unfortunately for some stupid reason these browser makers thought it would be a good idea to have their browsers try and correct mistakes in the web pages which of course is a very bad idea because if you do make a mistake then you are unlikely to catch it.
__________________
Spookster CodingForums Tyrant All Hail Spookster Where do you want to go today? Microso... errr Wrong!!! Make the switch Ubuntu Linux |
|
|
|
|
|
PM User | #5 |
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
Well, optional is just the term the W3C uses. They are, according to the spec, required to be present but have optional start tags, so while they must be present in the document representation, they are not required in the actual document. As you can see in my minimal valid HTML 4.01 Strict document above.
This is not an effect of browser implementations, it's an effect of less-than-perfect SGML application engineering, by the IETF and later W3C.
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards |
|
|
|
|
|
PM User | #6 | |
|
The Infractionator-inator ![]() ![]() Join Date: May 2002
Location: Marion, IA USA
Posts: 5,605
Thanks: 3
Thanked 21 Times in 21 Posts
![]() |
Quote:
__________________
Spookster CodingForums Tyrant All Hail Spookster Where do you want to go today? Microso... errr Wrong!!! Make the switch Ubuntu Linux |
|
|
|
|
|
|
PM User | #7 |
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
As I said, it's less-than-perfect engineering on part of those writing the standards. Have a look at the DTD if you don't believe me:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!ELEMENT HTML O O (%html.content;) -- document root element --> <!ELEMENT HEAD O O (%head.content;) +(%head.misc;) -- document head --> <!ELEMENT TITLE - - (#PCDATA) -(%head.misc;) -- document title --> <!ELEMENT BASE - O EMPTY -- document base URI --> <!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body --> <!ENTITY % html.content "HEAD, BODY"> <!ENTITY % head.content "TITLE & BASE?"> What you can read out of this is: - The HTML element is required on behalf of being the root element specified in the doctype. It MUST contain one (and only one) HEAD element followed by one (and only one) BODY element, and nothing else. However, the part I've marked red also specifies that both start and end tag is optional. - The HEAD element is thus required. Also here, however, start and end tags are both optional. It must contain one (and only one) TITLE element, in addition to one or zero BASE elements and any number of other HEAD content elements. - The TITLE element may only contain parsed character data, no tags. As I've marked green here, it's start and end tags are required. - The BASE element is included here only as comparison - this element is empty (may not contain anything) and as marked blue here, opening tag is required while end tag is optional. - The BODY element, also required, has optional start and end tags too. It must contain one or more block or SCRIPT elements, and may contain INS and DEL elements. Thus, a valid HTML document requires only the DOCTYPE, the TITLE and a block element. The user agent is REQUIRED to fill out the optional start and end tags for it's document representation. (which many browsers fail to do as they should) Thus there exists a HTML, HEAD and BODY element even if the document doesn't explicitly specify them, because the browser should deduce where they should be from the other elements present in the document. That means you SHOULD be able to among other things style the body element even if it's not present in the actual document. Browsers, however, in their search to render everything thrown at them, very seldom do the correct deductions if they do them at all. Try the following for instance: Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<title>experiment</title>
<style type="text/css">
html{
background-color: #ffa;
color: #006;
padding: 2em;
}
body{
background-color: #aff;
color: #600;
padding: 2em;
}
p{
background-color: #faf;
color: #060;
padding: 2em;
}
</style>
<p>paragraph
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards Last edited by liorean; 10-17-2003 at 06:30 PM.. |
|
|
|
|
|
PM User | #8 |
|
The Infractionator-inator ![]() ![]() Join Date: May 2002
Location: Marion, IA USA
Posts: 5,605
Thanks: 3
Thanked 21 Times in 21 Posts
![]() |
Well if that is indeed true I think we should just ignore that and promote what should be the proper way of setting up the page using the minimum set of tags as posted earlier. I think discussing that would only aid in confusing newbies.
__________________
Spookster CodingForums Tyrant All Hail Spookster Where do you want to go today? Microso... errr Wrong!!! Make the switch Ubuntu Linux |
|
|
|
|
|
PM User | #9 |
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
Well, I always promote the XML/XHTML way anyway...
I'd say you should recommend them a minimum document with a doctype though, and be sure to add the <meta content="text/html;charset=utf-8;" http-equiv="Content-Type" /> element directly following the opening head tag, just because.
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards |
|
|
|
|
|
PM User | #10 |
|
Regular Coder ![]() Join Date: Apr 2003
Location: UK
Posts: 226
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
In order to make a valid document, you also need the Content-Type meta tag to state which character set the page uses (unless the server already sends it in the HTTP headers).
More on <head> structure in: http://www.codingforums.com/showthre...threadid=27444 |
|
|
|
|
|
PM User | #11 | |
|
The Infractionator-inator ![]() ![]() Join Date: May 2002
Location: Marion, IA USA
Posts: 5,605
Thanks: 3
Thanked 21 Times in 21 Posts
![]() |
Quote:
__________________
Spookster CodingForums Tyrant All Hail Spookster Where do you want to go today? Microso... errr Wrong!!! Make the switch Ubuntu Linux |
|
|
|
|
|
|
PM User | #12 | ||
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
Quote:
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards |
||
|
|
|
|
|
PM User | #13 |
|
The Infractionator-inator ![]() ![]() Join Date: May 2002
Location: Marion, IA USA
Posts: 5,605
Thanks: 3
Thanked 21 Times in 21 Posts
![]() |
lol
Yeah so. I don't think there are any forum rules against agreeing with yourself.
__________________
Spookster CodingForums Tyrant All Hail Spookster Where do you want to go today? Microso... errr Wrong!!! Make the switch Ubuntu Linux |
|
|
|
|
|
PM User | #14 | |
|
The Infractionator-inator ![]() ![]() Join Date: May 2002
Location: Marion, IA USA
Posts: 5,605
Thanks: 3
Thanked 21 Times in 21 Posts
![]() |
Quote:
__________________
Spookster CodingForums Tyrant All Hail Spookster Where do you want to go today? Microso... errr Wrong!!! Make the switch Ubuntu Linux |
|
|
|
|
|
|
PM User | #15 | |
|
The thread killer ![]() ![]() Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
![]() |
Quote:
You know, they say talking to yourself is the first step towards insanity.
__________________
liorean <[lio@wg]> Articles: RegEx evolt wsabstract , Named Arguments Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|