你引用HTML5属性吗? [英] Do you quote HTML5 attributes?

查看:123
本文介绍了你引用HTML5属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML5中的属性引用是可选的



引用它们的优点/缺点是什么?

  id = example<! -  quotes optional  - > 
href = http://example.com<! - quotes optional - >
class =示例示例-1<! - 由于空间需要的引号 - >
href =http://example.com/p=47<! - 由于'='符号所需的引号 - >

更新:根据答案增加优势:

引用所有属性的优势:


  • 所有编辑器都可以正确处理它。
  • 更多
  • more一致

  • 更好的可移植性(易于更改doctype)

  • 更容易维护(特别是如果属性可能为空)
  • 更容易'查找和替换'更改

  • 更清洁的文档(如果您认为引号改善了可读性)



  • $ b

    优点忽略可选引号:


    • 稍微减少文件大小

    • 清洁文档(如果您偏好最少的文字)



    解决方案

    我赞成始终使用引号。


    • 它看起来更清晰,更一致

    • 所有编辑者都可以正确处理它

      / li>
    • 这更容易o维护 - 您可以在不破坏引号的情况下编辑值,因为缺少引号。

    • 通过删除不需要的引号不值得一提(除非你是Google的主页)。


      Attribute quotes are optional in HTML5.

      What are the pros/cons to quoting them?

      id=example                     <!--quotes optional-->
      href=http://example.com        <!--quotes optional-->
      class="example example-1"      <!--quotes required due to space-->
      href="http://example.com/p=47" <!--quotes required due to '=' sign-->
      

      Update: Added advantages based on the answers:

      Advantages to quoting all attributes:

      • all editors can deal with it properly
      • more consistent
      • better portability (easier to change doctype)
      • easier to maintain (esp. if attributes might become empty)
      • easier to 'find and replace' changes
      • cleaner doc (if you think quotes improve readability)
      • ?

      Advantages to omitting optional quotes:

      • slightly reduced filesize
      • cleaner doc (if you prefer minimal text)
      • ?

      解决方案

      I'm in favour of always using quotes.

      • It looks way cleaner and more consistent

      • All editors can deal with it properly

      • It's easier to maintain - you can edit values without breaking them because quotes are missing.

      The few bytes you save in document size by dropping quotes where they are not needed are not worth mentioning (unless maybe you're Google's home page).

      这篇关于你引用HTML5属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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