When does whitespace matter in HTML?

前端 未结 3 1730
慢半拍i
慢半拍i 2020-11-30 07:22

example 1

<
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 07:56

    HTML collapses serial whitespaces to a single whitespace, but doesn't eliminate it. A newline is a whitespace, therefore a space.

    It's not just leading/trailing - serial whitespace within an element is rendered as single whitespace as well. These will render identically:

    a b
    a b
    a b

提交回复
热议问题