love
V2EX  ›  编程

既然 html5 允许省掉属性的引号,那为了美观你们打算省掉吗?

  •  
  •   love · Aug 2, 2014 · 5293 views
    This topic created in 4477 days ago, the information mentioned may be changed or developed.
    以前,由于xml洁癖,我这么写:
    <input type="text" name="username" disabled="disabled" />

    后来这么写:
    <input type="text" name="username" disabled>

    以后打算就这样了好吗:
    <input type=text name=username disabled>

    是不是更清爽?
    9 replies  •  2014-09-22 18:46:28 +08:00
    xream
    xream
    Aug 2, 2014
    1
    看模板 Jade 里不带引号就是变量...
    helone
    helone
    Aug 2, 2014
    2
    。。。楼主你考虑不支持html5浏览器的感受了么?
    s5s5
    s5s5
    Aug 2, 2014
    3
    你的代码是写给小伙伴看的,加上是不是更友好些呢?
    去掉的工作可以交给发布前的优化工具来做
    cbsw
    cbsw
    Aug 2, 2014
    4
    Flask 文档中也是没有引号的
    arzusyume
    arzusyume
    Aug 2, 2014
    5
    <input class="xxx disabled" />
    yuyachen
    yuyachen
    Aug 3, 2014
    6
    我还是觉得第一种最舒服
    SoloCompany
    SoloCompany
    Aug 3, 2014
    7
    无歧义可省略引号这难道不是 HTML1.0 就是这样的吗(假如有1.0的话
    jakwings
    jakwings
    Aug 3, 2014
    8
    假如要难为爬虫的话……没有引号就不方便快速在内容始末跳转了啊,编程语言里有大括号做标记还是挺方便的。完全美观不现实啊……


    @helone HTML4 时代早允许那样写了,而且有好多人那样写过。
    kofip
    kofip
    Sep 22, 2014
    9
    这样写,不会有歧义吗?

    解析器 应该会很郁闷。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1324 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 19:55 · PVG 03:55 · LAX 11:55 · JFK 14:55
    ♥ Do have faith in what you're doing.