周四. 4月 25th, 2024

建议遵循

多数的网站或者博客中,都会引用一些其他网站提供的代码,以实现一些功能或者动态的广告条目,但直接复制用来的话,会发现部分代码就会导致很多的HTML校验错误,因此有必要注意一下代码的规范性。

1.Twitter网站生成的侧边栏代码里包含如下不符合标准:

[code=’xhtml’]

    [/code]
    话说如“ <head>”之类的元素必须包含一个“<title>”子元素,名单的 (ul, ol, dl)等必须包含一个子项(li,or dt, dd)等等,于是这样处理通过校验:

    [code=’xhtml’]

    [/code]
    不过添加的标签可能会使放置位置的某些样式发生变化,需要按实际情况处理。

    2.Yupoo网站自动生成的侧边栏代码包含如下不符合标准:
    [code=’js’]

    [/code]
    校验时提示:

    …cannot generate system identifier for general entity “source”

    An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling the reference name, unencoded ampersands, or by leaving off the trailing semicolon (;). The most common cause of this error is unencoded ampersands in URLs as described by the WDG in “Ampersands in URLs”.

    Entity references start with an ampersand (&) and end with a semicolon (;). If you want to use a literal ampersand in your document you must encode it as “&amp;” (even inside URLs!).

    一些链接脚本内的&符号不符合标准,必须全部替换为&amp;,这是很多外链脚本与广告脚本里常常出现的问题,必须想办法将原文件替换。

    不建议遵循

    为表单的某些含敏感数据的元素关闭自动完成(Turn off autocomplete),如信用卡号码、密码等。让自动完成保存敏感信息将是一个不小的安全隐患。

    <input type="text" name="cc" autocomplete="off" />

    关闭整个表单的自动完成

    <from name="form" autocomplete="off">

    autocomplete 属性很早便得到了多数浏览器的支持,由于可能是晚于 W3C 对 XHTML 标准的定义,因此无法通过 W3C 的校验。

    BTW:autocomplete 属性在 HTML5 中已成为标准属性

    作者 Chris

    发表评论

    您的电子邮箱地址不会被公开。 必填项已用*标注

    此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据