alter
alter

Reputation: 4426

Code is not behaving in strict mode

Can some body explain why the TD element is taking width when its not allowed in strict mode.This is the code [Was not able to put code because of HTML rendering problem.]

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

<html>

<head>
 <meta http-equiv="Content-Type" content="text/xml+xhtml; charset=utf-8"/>
</head>
<body>
<table>
<tr>
    <td width="200">First</td>
    <td>Second</td>
</tr>
</table>

</body>
</html>

Upvotes: 0

Views: 93

Answers (4)

alter
alter

Reputation: 4426

I did everything suggested but it still it is taking width attribute. I think it is because of browsers have to support it now but future browsers will throw an error on code like this

Upvotes: 0

BoltClock
BoltClock

Reputation: 723568

Your doctype (HTML 4.01) doesn't match your content type.

The content type should read application/xhtml+xml instead of text/xml+xhtml, and your web server should also serve your page as such in order for standards-compliant browsers to treat it strictly (that is, fail to render your document if it's invalid). Also, as Alohci says, you need to include an XML namespace for the XHTML spec.

<html xmlns="http://www.w3.org/1999/xhtml">

Otherwise, browsers will just render like you tell them to, ignoring standards, although if you try to validate this it'll still fail.

Upvotes: 0

mvime
mvime

Reputation: 337

Since you specified it the browser will apply it, but your document won't validate.

Upvotes: 0

meder omuraliev
meder omuraliev

Reputation: 186562

Even though it's deprecated per the spec the browser will still apply it because you specified it. It has to be lenient toward older docs which may otherwise have broken layouts if it didn't apply the attribute(s).

Upvotes: 1

Related Questions