String attribute values in multiple lines, HTML

前端 未结 6 812
清歌不尽
清歌不尽 2020-12-03 17:24

Is it possible, in HTML to write something like:

....

The idea is spl

6条回答
  •  时光说笑
    2020-12-03 17:56

    No, it is not possible. HTML has no “line continuation” character. If you put a line break in an attribute value, browser behavior varies, but modern browsers behave in the manner documented in HTML5: a line break is allowed, and it is taken literally and stored as a line break in the DOM. This means that href attribute value is broken and does not work.

    The best you do to alleviate the problem of long href values is to put such a value on a line of its own, without quotation marks:

    link
    

    In contrast, the following is allowed and causes as two-liner tooltip (in modern browsers). The point is that the general syntax allows line breaks, but they have consequences, and the specific syntax of an attribute may forbid line breaks.

    bar
    

提交回复
热议问题