Search code examples
htmlw3cline-breaks

Why is <br> an element, not an entity?


Possible Duplicate:
Why is <br> an HTML element rather than an HTML entity?

Why is a line break in HTML an element <br> instead of an entity, such as &br;? In many ways it seems a bad fit to be an element (e.g. has a different node type attribute to normal HTML elements, is similar to &nbsp; in what it does).


Solution

  • From the spec*

    The br element represents a line break.

    While line breaks are usually represented in visual media by physically moving subsequent text to a new line, a style sheet or user agent would be equally justified in causing line breaks to be rendered in a different manner, for instance as green dots, or as extra spacing.

    br elements must be used only for line breaks that are actually part of the content, as in poems or addresses.

    So it states clearly that it is ok to style a line break as something else, thus justifying why it's not an entity. It does make me think that there should be two ways of adding a line break - as an entity &br; or a tag <br>, thus giving the author flexibility over whether the line break is stylable or not. The statement above - equating use of line breaks in poems and addresses - is a bit of a broad brush if you ask me.

    *Not sure if it's the spec, but it's certainly a spec