HTML characters


HTML entities (in Qwwwik)

&lt; is an HTML entity for < which a browser reads as literal HTML for opening a tag. If the content of a web page contains < >, nothing will show because the browser thinks it's some of HTML's 'reserved characters'. Reserved characters are always parsed as HTML otherwise HTML can't exist. If a web page contains <hr> you want it to show a horizontal rule.

An HTML entity is a sequence of characters like &lt; which will always show as a literal < and not be parsed as HTML.

<form> <textarea>

If you are using a textarea to write HTML, you need the textarea to display < as < or you won't know what you wrote. A browser will because it's HTML but you won't unless it's converted to an HTML entity specifically for the textarea. What you do in PHP is use htmlentities to convert all reserved characters into HTML entities so the < you wrote becomes &lt; in the markup for the textarea to show as < (but only in the textarea – in the actual web page it's HTML).

HTML special characters

As stated, < is a special 'reserved character' read by a browser as HTML. In PHP you can use htmlspecialchars to convert special characters like < into HTML entities like &lt; to display in a web page as the < you actually wrote. It will not then be parsed by a browser as HTML.

See information

Page last modified: 23 April, 2024
Search | Legal | Qwwwik

Info