问题描述
我正在研究文档类型,以找到最适合我的文档类型。我正在考虑使用严格的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”还在工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!