tags:

views:

47

answers:

2

I'm not a front-end programmer, but I first realized the issue just when I found the css.maxHeight is not supported by HTML4.0. when the DOCTYPE refers to HTML4.0, maxHeight in css doesn't work, but change the DOCTYPE to XHTML1.0, it works.

So, now have the question, What the difference between the support for css by HTML4.0 and XHTML1.0? or, where can I get the comparison chart or statistic?

Edit: -- sorry for the mistype, it's maxHeight not maxLength--

what the css.maxHeight i mean is just by the simple code as below, the backgroundColor works in HTML4.0 but maxLength no.

<script languague="javascript" type="text/javascript">
    $(document).ready(function() {
          var div = $("div");
          div.css({ maxHeight: 200,
              overflow: 'auto',
              backgroundColor:'#eee'
          });
    });
</script>

and here is the two type of DOCTYPE references

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
+2  A: 

There is (or at least should) be no difference. CSS is independent of (X)HTML. You can use HTML 4 with CSS 3 if the browser supports CSS 3 features. XHTML 1.0 is basically HTML 4 in XML syntax with some presentation related tags and attributes deprecated.

Having said that. If you see differences between those pages then you're probably seeing the browser switching between quirks and standards compliant mode. You said you just changed the DOCTYPE from HTML 4 to XHTML. Did you also rewrite the rest of the document to be XML compliant for XHTML too?

Martin Maciaszek
no, here is my code sample, http://notepad.cc/heaqioxo5just take off either of the two DOCTYPE (html4 or xhtml1), you'll get different result. So now i'm interested in what the difference behind the implementation
Elaine
you can also kindly check out the Edit part in the post, thanks.
Elaine
You just changed the DOCTYPE and left the rest unchanged. You have some <br> and <br /> in the same document. When using XHTML the browser expects a well formed XML document. Seeing those tags it will most probably switch into squirks mode. With the html 4 doctype browsers tend to be a bit more forgiving about such errors.To make things even worse I tried both versions of that document in Safari 5 and they look exactly the same. (see http://skitch.com/fastjack/djph5/1-2-3-4-5)
Martin Maciaszek
While we're at it. Is there some reason why you apply the styles with javascript instead of just a regular style sheet?
Martin Maciaszek
you're right, I got an article here to implement maxHeight by javascript in IE6. but which is not what I really want. I just curious about is there any a complete XHTML/HTML comparison list there that shows the support statistic for TAG/CSS Properties and everything.. but seems I still cannot find it out..
Elaine
here is that article I mentioned above, 'Ultimate IE6 Cheatsheet: How To Fix 25+ Internet Explorer 6 Bugs'http://www.virtuosimedia.com/tutorials/ultimate-ie6-cheatsheet-how-to-fix-25-internet-explorer-6-bugs
Elaine
+2  A: 

Using different versions of HTML doesn't really have anything to do with the support for CSS. The different versions of CSS is independent of the versions of HTML.

What can matter is if the page renders in standards compliant mode or quirks mode. If you don't have a proper doctype tag, the browser thinks that it's an old page before the era of standardisation and reverts to quirks mode where it tries to be backwards compatible with ancient versions of browsers.

The sets of features that the browser supports are different for standards compliant mode and quirks mode, mostly it's non-standard features that are disabled in standards compliant mode.

I'm not sure what you mean by "css.maxLength" as there is no maxlength property in CSS. There is a maxlength attribute in HTML for textboxes, and that is supported in all versions of HTML.

Guffa
yes, you can get where I got the confusion from the code here (too long to be allowed to paste here) ---http://notepad.cc/heaqioxo5 just take off either of the two DOCTYPE (html4 or xhtml1), you'll get two different results.I just need a WHY..
Elaine
@Elaine: It's only in IE that you get that specific difference. The HTML doctype is non-standard, so it renders in quirks mode, and the quirks mode in IE is especially quirky (mostly emulating IE4, which was before maxheight existed). If you use a standard doctype for HTML 4.01 from http://www.w3.org/QA/2002/04/valid-dtd-list.html so that the page renders in standards compliant mode, they work the same in IE too.
Guffa
SO HELPFUL, thank you a lot :)
Elaine