如果选择了xhtml1.0,就需要知道的

在书写html文件的时候,如果选择了如下的声明就表明了您正在尝试使用xhtml1.0的标准:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

当然.dtd文件也可能是xhtml1-strict.dtd或者xhtml1-frameset.dtd,但是比较常用的标准还是xhtml1-transitional.dtd。对于标准的使用不仅仅是.dtd的问题,其中还涉及到您定义的css和javascript,如果仅仅是使用标准的声明而没有严格的按照其说明来书写css或者javascript的话,肯能会遇到让人比较头大的问题,为了避免这些情况的发生,请努力做到如下几点:
1、格式良好的html定义。这里的格式良好与xml的概念相同,也就是每一个元素都需要有开始和结束标记如<br/>、<p>your need end it</p>
2、元素和元素的属性需要小写格式的,也就是说:<br/>最好不要书写为<BR/>、<table border="2">也不要写为<table BORDER="1">尽管这些大写的格式也是可以被识别的
3、非空元素需要加上结束标记如<div>tag contents</div>,这一点和1的要求类似
4、元素的属性值需要使用双引号如<div id="needquoteme"></div>
5、attribute minimization.因为在xml中attribute minization is not supported.sou if we use checked attribute we need to give it the value "checked".etc.<input type="radio" checked="checked"/>,而不能书写为 <input type="radio" checked>尽管这样也可以正常工作
6、如果元素可以为空则需要加上结束标记或者"/>"如:<br></br>也可以书写为<br/>
7、White Space handling in attribute values
* Strip leading and trailing white space.
* Map sequences of one or more white space characters (including line breaks) to a single inter-word space
8、script 和style element
xhtml1.0中提倡的写法为<script type="text/javascript">
<![CDATA[
... unescaped script content ...
]]>
</script>
但是这种方法在实践中好象还是走不通的,似乎现在的浏览器对此的识别能里还很有限
9、SGML exclusions
10、The elements with 'id' and 'name' attributes
在xhtml1.0的标准中不在提倡使用name属性,建议使用id
11、Attributes with pre-defined value sets
HTML 4 and XHTML both have some attributes that have pre-defined and limited sets of values (e.g. the type attribute of the input element). In SGML and XML, these are called enumerated attributes. Under HTML 4, the interpretation of these values was case-insensitive, so a value of TEXT was equivalent to a value of text. Under XML, the interpretation of these values is case-sensitive, and in XHTML 1 all of these values are defined in lower-case.
12、Entity references as hex values

SGML and XML both permit references to characters by using hexadecimal values. In SGML these references could be made using either &#Xnn; or &#xnn;. In XML documents, you must use the lower-case version (i.e. &#xnn;)
这里说明的12中情况中1-8和10是需要特别注意的地方,切记切记,使用一个标准就要按照标准的要求办事,否则将会发生许多不必要的麻烦,比如可能一个style="width:10px"被遗忘了px而变成了style="width:10"导致了IE和FF的差异十万八千里…………
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值