Jump to content

Positioning not working with Doctype


Dug

Recommended Posts

Hi there,I'm trying to get the code for my website to W3C standard. The Doctype I'm using is:

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

The problem is that CSS positioning doesn't seem to work when I use Doctypes. It works without the Doctype though. For example, the positioning code I'm using is:

position: absolute; top: 200; left: 200;

This code is in the

#welcome

and on the page itself:

<div id="welcome">

.I'm using Dreamweaver for my site. Has anyone had this problem before? If so, what's the best way to position things?ThanksDouglas

Link to comment
Share on other sites

I would use xhtml 1.0 vs. html.Just a cleaner way. Why use "older" stuff when the new is better?Try this doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

Really, there isn't that much difference.*edit*make sure you use px for a unit (or at least some sort of unit)

Link to comment
Share on other sites

Well, I managed to get it working finally. The one that seems to work is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

I was trying to get it working with the default Dreamweaver Doctypes. Don't know what went wrong.Dug

Link to comment
Share on other sites

Unfortunately this means your page is coded in a way that it relies on browsers to be in quirks mode. http://hsivonen.iki.fi/doctype/ is a useful table where you can see which doctypes activate which rendering mode in many browsers. You'll get the same effect using

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

and no doctype.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...