【问题标题】:For HTML attributes with only one possible value, can the value be omitted?对于只有一个可能值的 HTML 属性,可以省略该值吗?
【发布时间】:2014-07-05 00:17:40
【问题描述】:

我正在使用一些使用框架的古老 Web 应用程序。 <frame>有一个属性叫noresize,其值只能指定为"noresize"。我在代码中注意到 noresize 没有赋值:

<frame name="client_search_banner" src="pdc?page=client_search_banner.htm" noresize scrolling="no">

起初我认为noresize scrolling 是一个属性,但从我读过的所有内容来看,它们似乎是两个完全不同的东西。我想知道在这种情况下是否假定该值,因为只有一个可能的值。有人可以确认一下吗?

【问题讨论】:

    标签: html


    【解决方案1】:

    在 HTML 4.01 及更早版本中,you can omit everything except the attribute value

    在 XHTML 中,you cannot omit anything

    在 HTML 5 和更新版本中,you can omit everything except the attribute name

    由于 HTML 中布尔属性的名称和值始终相同,因此 HTML 4 和 5 规则实际上是相同的。

    【讨论】:

      【解决方案2】:

      这些被称为布尔属性。在 XHTML 中,它们必须有一个值,但在 HTML 中,可以省略该值。如果它在那里,它的价值也没有什么区别。

      【讨论】:

        【解决方案3】:

        noresize 是一个布尔属性。当它存在时,它是真的,当它不存在时,它是假的。有关 noresize 和其他属性的更多详细信息,请参阅 W3C 文档。

        http://www.w3.org/TR/html401/present/frames.html

        【讨论】:

          猜你喜欢
          • 2014-07-02
          • 1970-01-01
          • 1970-01-01
          • 2017-02-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-08-05
          相关资源
          最近更新 更多