Single quotes in data attribute containing json

前端 未结 5 1480
清酒与你
清酒与你 2021-02-12 21:06

Cosmetic question: I have a html element containing possible dimensions for some embedded images, these are stored as:

5条回答
  •  不要未来只要你来
    2021-02-12 22:08

    The JSON specification stipulates that keys and (string) values be quoted with double-quotes.

    HTML attributes can be enclosed in either single or double quotes.

    Personally, I wouldn't fight it and just go with what causes the least amount of friction and is easiest for all to understand which in this case is to single quote the HTML attributes and use double-quotes inside the attribute value.

提交回复
热议问题