Does XML Spec define that it is illegal to have whitespace before self closing slash?

前端 未结 1 1405
生来不讨喜
生来不讨喜 2021-01-22 15:44

I am talking XML document not HTML. Since in HTML,
and
are both valid. Want to know if XML specification defines whether it is

1条回答
  •  故里飘歌
    2021-01-22 16:37

    The space at the end is allowed for "normal" tags as well as for empty elements, see https://www.w3.org/TR/xml/#sec-starttags:

    Start-tag

    STag ::= '<' Name (S Attribute)* S? '>'

    Tags for Empty Elements

    EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'

    Notice the S? at the end which optionally allows one or more whitespace characters at the end:

    S ::= (#x20 | #x9 | #xD | #xA)+

    0 讨论(0)
提交回复
热议问题