Log in

View Full Version : DOCTYPE -- Grr!



Jas
02-23-2008, 11:59 PM
I have never had a problem with html, but this won't work and it's making me really really really mad! :mad::mad::mad:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
</head>
<body>
<!-- this shows up as nothing//-->
<div style="height:100%;width:100%;background-color:#123456;"></div>
</body>
</html>

The problem seems to be the doc type, which w3c requires for valid html. What can a guy do? I tried other DOCTYPEs as well, but the only ones that work are invalid. I am really confused and frustrated.

Master_script_maker
02-24-2008, 01:32 AM
you need title tag, even if it is empty:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
</head>
<body>
<!-- this shows up as nothing//-->
<div style="height:100%;width:100%;background-color:#123456;"></div>
</body>
</html>

Jas
02-24-2008, 04:10 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<!-- this shows up as nothing//-->
<div style="height:100%;width:100%;background-color:#123456;"></div>
</body>
</html>
Still does not work. I don't get it. In FF, nothing shows up at all, in IE, the demensions are default. It's like the hieght and width don't exist.

If you take out the DOCTYPE, it suddenly works. What is going on?!

Nile
02-24-2008, 04:21 AM
I don't think that this will work but try it anyways:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<!-- this shows up as nothing//-->
<div style="height:100%;width:100%;background-color:#123456;"></div>
</body>
</html>

Jas
02-24-2008, 04:26 AM
Good eye, but no, it didn't work. Try pasting it into an HTML file. It's really strange.

Is it just my computer? :confused:

Nile
02-24-2008, 04:32 AM
I think so, because I tried both of 'em
and it works perfectly.

djr33
02-24-2008, 08:05 AM
Sometimes having content will change whether or not something displays (ie add &nbsp; to the div), and also that color isn't valid-- it must be in the form of AABBCC where A, B, and C are values from 0-F (0-9,A-F). It usually works, but technically the web is only meant to have 256 colors (which are determined by what I just said).

Twey
02-24-2008, 10:02 AM
The 100% height will be ignored, because you don't have an explicit height for the parent element. You also need 100% height on the <body> and the <html>. It's bad practice to use inline styles.
that color isn't valid-- it must be in the form of AABBCC where A, B, and C are values from 0-F (0-9,A-F).It's perfectly valid, and also includes the mandatory # you forgot to mention. :) Note that that's only one colour form -- there are others, like rgb(255, 255, 255) (equivalent to #FFF) or #FFF (equivalent to #FFFFFF).

djr33
02-24-2008, 10:27 AM
Well, maybe it's valid then, I'm not sure, but it isn't technically supported by all systems, though that may be outdated. Anyway, seems the problem was found.

Jas
02-24-2008, 02:49 PM
I think so, because I tried both of 'em
and it works perfectly. Are you sure it did what it was suppose to?


The 100% height will be ignored, because you don't have an explicit height for the parent element. You also need 100% height on the <body> and the <html>.


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Hello World!</title>
</head>
<body style="height:100%;">
<!-- this shows up as nothing//-->
<div style="height:100%;width:100%;background-color:#123456;"></div>
</body>
</html>

Did not work. What should I do to get the effect I am obviously seeking?

NVM! Twey you rock! I added the height to the HTML tag and it works!

And DJR33, what is wrong with the color?
AA | BB | CC
12 | 34 | 56

Twey
02-24-2008, 04:54 PM
He was trying to say that the digits of the RGB pairs in colours must match, as in #112233 or #2255EE. He's wrong, ignore him :) He was probably thinking of the "websafe" colours (http://www.web-source.net/216_color_chart.htm), but those aren't really much of an issue any more -- few people have 16-bit displays nowadays, and those that do can put up with a bit of dithering, it's hardly an accessibility issue.

Jas
02-24-2008, 06:56 PM
Oh, I see. Talking about the old school stuff. :) That would limit color choices. I think almost every browser/computer supports more colors than that now days, and all my tests have worked, so I am not worried. But djr33 is right, to an extent. It's better safe then sorry. (Of course, my motto is, if your using a browser older then IE5 or a computer older then winME, you need to update. I don't have time to work out the problems for you.)