xhtml & margin-top

B

bernhard schelling

hi,
by migrating an existing site to xhtml i encountered a strange behaviour in
Firefox & Opera:
If I change the doctype to xhtml the top-margin on the form element seems
to go up -

<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style>
#search{
margin-top:95px
}
</style>
</head>
<body>
<div style="height:100px;border:1px red solid"><input type="text"
id="search"/></div>
</body>
</html>

any hints?
thanks in advance
bernhard
 
S

Spartanicus

bernhard schelling said:
by migrating an existing site to xhtml

Generally not a wise move:
http://www.spartanicus.utvinternet.ie/no-xhtml.htm
i encountered a strange behaviour in
Firefox & Opera:
If I change the doctype to xhtml the top-margin on the form element seems
to go up -

<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Nowt to do with "XHTML", it's due to the change from quirks mode
triggered by transitional doctype sans url to standard compliant mode
triggered by the XHTML Strict doctype
 
R

richard_quick_uk

Hi,

Try this instead...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DT D/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Title</title>
</head>
<body>
<div style="min-height:12px;border:1px red solid; padding-top:
95px;"><input type="text" id="search"/></div>
</body>
</html>

If you're using xhtml strict you first need to make sure your page
validates (hence the inclusion of <title> tags etc).

The main problem here seems to be that you'd set the height attribute,
which Mozilla interprets correctly as a fixed height (with any content
overflowing the div by default) while IE incorrectly interprets height
as a minimum height (expanding the div to fit the content by default).

Hope this helps,

Richard Quick
 
T

Toby Inkster

Robert said:
Why tee hee hee?

The Content-Type header indicates that the file is HTML, but the "/>"
at the end of the meta tag indicates that it's XHTML.

Should really be either:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
or:
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1">
 
E

Els

Toby said:
The Content-Type header indicates that the file is HTML, but the "/>"
at the end of the meta tag indicates that it's XHTML.

Should really be either:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
or:
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1">

With a slash on the last one I suppose? ;-)
 
R

richard_quick_uk

Which is great in theory - except IE doesn't support:

<meta http-equiv="Content-Type" content="application/xhtml+xml ;
charset=iso-8859-1" />

So you have to serve it as text/html
 
T

Toby Inkster

richard_quick_uk said:
Which is great in theory - except IE doesn't support:
<meta http-equiv="Content-Type" content="application/xhtml+xml ;
charset=iso-8859-1" />

It doesn't generally pay the slightest bit of attention to the META tags
at all, so you may use the above construct with no negitive consequences.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top