Why is
an HTML element rather than an HTML entity?

前端 未结 8 1678

Why indeed? Wouldn\'t something like &br; be more appropriate?

8条回答
  •  生来不讨喜
    2020-12-09 07:50

    HTML is a mark-up language - it represents the structure of a document, not how that document should appear visually. Take the tag as an example - it tells user-agents that they should give emphasis to any text that is placed between the opening and closing tags. However, it does not state how that emphasis should be represented. Yes, most visual web-browsers will place the text in italics, but this is only convention. Other browsers, such as monochrome text-only browsers may display the text in inverse. A screen reader might read the text in a louder voice, or change the pronunciation. A search-engine spider might decide the text is more important than other elements.

    The same goes for the
    tag - it isn't just another character entity, it actually represents a break in the document structure. A > is not just a replacement for a newline character, but is a "semantic" part of the document and how it is structured. This is similar to the way an

    is not just a way of making text bigger and bolder, but is an integral part of the way the document is structured.

提交回复
热议问题