XHTML 1.0严格-div align =“ center”还在工作? [英] XHTML 1.0 Strict - div align="center" still working?

查看:92
本文介绍了XHTML 1.0严格-div align =“ center”还在工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究文档类型,以找到最适合我的文档类型。我正在考虑使用严格的XHTML 1.0,因为它不应该接受不推荐使用的元素和属性。
为了测试行为,我创建了一个包含以下内容的html页面:

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

< html xmlns = http://www.w3.org/1999/xhtml>
< head runat = server>
<元http-equiv = Content-Type content = text / html; charset = utf-8 />
< title>< / title>
< / head>
< body>
< div align = center>
一些文本
< / div>
< / body>
< / html>

当我使用Firefox打开此控件时,div的宽度为100%(可以),其文本为居中对齐(这不行,不再应该使用align属性)。



有人可以解释为什么会这样吗?我是在做错什么还是在严格模式下仍接受某些不赞成使用的属性?

解决方案

文档类型切换触发的标准模式无关强制缺乏对过时/删除的属性的支持。它的大多数作用是在CSS支持中禁用错误​​的仿真(例如 width 的不正确处理,并假定整数值为像素值)。



使用验证器来检测何时使用不推荐使用的HTML功能。 / p>

I'm playing around with the doctypes to find the best one for me. I'm thinking about to use XHTML 1.0 strict, because it shouldn't accept the deprecated elements and attributes. To test the behaviour, I created an html page with the following content:

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <div align="center">
        Some Text
    </div>
</body>
</html>

When I open this with Firefox the div has 100% width (which is ok) and it's text is aligned to center (which is not ok, the align attribute isn't supposed to work anymore).

Can someone explain why this is happening? Am I doing something wrong or are some deprecated attributes still accepted in strict mode?

解决方案

Doctype switching triggered Standards Mode has nothing to do with enforcing lack of support for deprecated/removed attributes. Most of the effects it has are on disabling the emulation of bugs (such as incorrect handing of width and assuming integer values are pixel values) in CSS support.

Use a validator to detect when you are using a deprecated HTML feature.

这篇关于XHTML 1.0严格-div align =“ center”还在工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆