Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

DOCTYPE causing CSS position not to work?

Here's a snippet of my code... (Changed some stuff, such as the title).
Code
<html>

<head>
<title>EXAMPLE</title>
<style>
A:link, A:visited{
color:red;
text-decoration:none;
}
</style>
</head>

<body>


<div style="position:fixed;top:155;left:35">
.
</div>

</body>

</html>

When I preview that, everything looks good. The "." is in the correct position.
[Image: sooHf.png]

But then when I add <!DOCTYPE html> (I'm pretty sure that's the correct doctype) the positioning doesn't work...

Code
<!DOCTYPE html>
<html>

<head>
<title>EXAMPLE</title>
<style>
A:link, A:visited{
color:red;
text-decoration:none;
}
</style>
</head>

<body>


<div style="position:fixed;top:155;left:35">
.
</div>

</body>

</html>

[Image: OrR2f.png]

This is in Firefox, but I've tested in other browsers. I've also tried using other doctypes...

Hopefully someone can help me :)
Try this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

or try this:
Code
<html>

<head>
<title>EXAMPLE</title>
<style type="text/css">
A:link, A:visited{
color:red;
text-decoration:none;
}
</style>
</head>

<body>

<div style="position:fixed;top:155;left:35">
.
</div>

</body>

</html>

and if any of those didn't work, try this:
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<title>EXAMPLE</title>
<style type="text/css">
A:link, A:visited{
color:red;
text-decoration:none;
}
</style>
</head>

<body>

<div style="position:fixed;top:155;left:35">
.
</div>

</body>

</html>

I hope I helped! =)
Specify a doctype before styling, this is common sense.

You created a style without rules, then added rules, what do you expect.

I'm not 100% sure but there have been other doctypes that dislike inline styling, the new html5 doctype might as well.
Dylan Wins...

Code
<html>

<head>
<title>EXAMPLE</title>
<style type="text/css">
A:link, A:visited{
color:red;
text-decoration:none;
}
</style>
</head>

<body>

<div style="position:fixed;top:155;left:35">
.
</div>

</body>

</html>

That works but it still doesn't specify a doctype first... don't I need to do that?
(Jul 22, 2012 06:39 PM)Nessie Wrote:  Dylan Wins...

Code
<html>

<head>
<title>EXAMPLE</title>
<style type="text/css">
A:link, A:visited{
color:red;
text-decoration:none;
}
</style>
</head>

<body>

<div style="position:fixed;top:155;left:35">
.
</div>

</body>

</html>

That works but it still doesn't specify a doctype first... don't I need to do that?
You need to specify your scripts for them to work properly.
Example:
<style type="text/css">
</style>

...and with the DOCTYPES, it all depends.

There is HTML 4.01 Strict, Transitional, and Frameset.

Strict:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

Transitional:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

Frameset:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">

You can try these 3.

I hope I helped. =)


Possibly Related Threads...
Thread / Author Replies Views Last Post
by randomFunPartyNov 19, 2019 04:22 AM 5 152 Nov 19, 2019 04:22 AM
Last Post: Nachfolger
by craigOwnsYouOct 13, 2019 04:00 AM 2 90 Oct 13, 2019 04:00 AM
Last Post: Nachfolger
by DaemonSicNov 26, 2017 07:15 AM 4 142 Nov 26, 2017 07:15 AM
Last Post: DaemonSic