It was thus said that the Great Fred Cisin once stated:
On Wed, 24 Dec 2008, Brent Hilpert wrote:
Are you asking how to get < and > rendered
as displayed text?
Try:
...the <BOLD> tag will...
(I'm not sure how I know this, I can't find it in the html reference I use;
which begs the question of whether it's actually part of the standard.)
< is the "less than" character
> is the "greater than" character
how would you get HTML to display:
"< is the "less than" character"
would I have to "escape" the ampersands?
&lt;
In HTML, "<" will display "<", while
"&lt;" would display "<".
Those are really the only two characters that need to be escaped to be
displayed literally; all others can be, but aren't required to.
<pre> , </pre> are fun.
Is there an inconsistency with whether a browser will display special
chatacters within a <pre> block? Do some browsers display them literally,
while others apply the <pre> ONLY to whitespace and line breaks?
I have seen at least one browser where I could get away with:
<pre>
x = <
if (x < y) . . .
</pre>
The <PRE> tag is just a method of specifying a monospace font that
preserves runs of spaces, tabs and linefeeds (normally, HTML will "collapse"
a run of spaces and only display a single space; tab and linefeeds are
treated as simple whitespace). You can still embed other tags within the
<PRE> tag, so if you want to display a literal '<' within a <PRE>
tag, you
need to specify it as "<".
Since I often blog examples of source code, I wrote a program that will
encode text properly for display within a <PRE> tag, converting:
if (x < 3)
{
printf("x needs to be higher\n");
}
<pre>
if (x < 3)
{
printf("x needs to be higher\n");
}
</pre>
(Technically, the double quote doesn't need to be converted, but I do it
anyway)
If you don't specify what level of HTML your document is conforming to
(using a <!DOCTYPE> declaration) then most browsers tend to fall back to
what's called "tag soup" parsing, and be *very* forgiving on what it's
parsing.
I guess that "modern" HTML has evolved to the point where one MUST use an
HTML generating program, and no more tampering with the raw HTML; just as
"nobody" writes Postscript.
No, I still write raw HTML---heck all my blog entries [1] are written in
raw HTML (beats trying to remember some half-baked ASCII markup monstrostity
like MarkDown), although the entries are pasted into a template when
requested.
-spc (Does this stuff for a living)
[1]
http://boston.conman.org/