Elaine
Elaine

Reputation: 1318

What the difference between the support for css by HTML4.0 and XHTML1.0?

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">

Upvotes: 0

Views: 1038

Answers (2)

Guffa
Guffa

Reputation: 700152

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.

Upvotes: 2

Martin Maciaszek
Martin Maciaszek

Reputation: 275

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?

Upvotes: 2

Related Questions