Home » Html » Right angle bracket in HTML

Right angle bracket in HTML

Posted by: admin November 29, 2017 Leave a comment


For obvious reasons, the left angle bracket cannot be used literally in HTML text. The status of the right angle bracket is not quite so clear. It does work when I try it, but of course browsers are notoriously forgiving of constructs that are not strictly valid HTML.

http://www.w3.org/TR/html4/charset.html#h-5.4 seems to be saying it’s valid, though may not be supported by older browsers, but also makes specific mention of quoted attribute values. Is it necessary to html encode right angle brackets? also says it’s valid but again specifically talks about quoted attribute values.

What’s the answer for plain chunks of text (contents of a <pre> Element happens to be the case I’m looking at), and does it differ in any way?


The character “>” can be used as such as data character in any version of HTML, both in element content and in an attribute value. This follows from the lack of any statement to the contrary in the specifications.

It is often routinely escaped as &gt;, which is valid but not required for any formal or technical reason. It is used partly because people assume it is needed the same way as the “<” character needs to be escaped, partly for symmetry: writing, say, &lt;code&gt; may look more symmetric than &lt;code>.

The character “>” is the GREATER THAN character. It is used in many contexts, like HTML markup, as a delimiter of a kind, in a bracket-like manner, but the real angle brackets, as used in some mathematical notations, are rather different, such as “⟩” U+27E9. If you need to include angle brackets in an HTML document, you have some serious issues to consider, but they relate to fonts (and semantics), not to any potential clash with markup-significant characters.


Right angle brackets are legal within a <pre> tag or as text within an element.

There is no ambiguity when using them in this manner and parsers have no issue with “understanding” them.

Personally, I just escape these whenever I need to use them, just to match left angle brackets…