Single and double quotes together as HTML attribute value?

后端 未结 2 1957
花落未央
花落未央 2020-12-10 08:57

We have a code like this:

echo \'\';

Absolutely it doesn\'t work b

2条回答
  •  隐瞒了意图╮
    2020-12-10 09:36

    To address the question in the title, there is no problem with using both " and ' in an attribute value. The problem arises in linearization of values, i.r. writing them in HTML markup (as opposite to generating them with client-side JavaScript). Then, if the value contains both " and ', either of them needs to be escaped, depending on which one you use as value delimiter.

    You do not need to use entity references, though. The character references " and ' (or the equivalent decimal references) can be used, too.

    In the case of the string

    She said: "I don't know."

    the correct English spelling is

    She said: “I don’t know.”

    Using the correct punctuation marks, no markup problem arises, since you can use the Ascii quotation mark " or the Ascii apostrophe as delimiter. They are meant for use in computer languages, not in human languages.

提交回复
热议问题