Basic question which I thought of asking on Superuser, but it is a programming question I think. I just started learning HTML, so please bear with me.
How can I prevent a program from interpreting an HTML tag / syntax? For example, I want to write a flash card like this:
The html code for <
is <
I would like a solution that would work for any or most syntax, not just for <
.
How can I enter the syntax (without any space) to make sure the code isn't interpreted?
You are going to have to do it manually.
Here you have the full encoding table. The most commonly used codes are:
Character Entity Number Entity Name Description
" " " quotation mark
' ' ' apostrophe (does not work in IE)
& & & ampersand
< < < less-than
> > > greater-than
This:
The html code for < is &lt;
Renders as:
The html code for < is <
The basic strategy is to escape the &
as &
I suppose you don't want the entity to be rendered? If you want to display <
you'll have to use the entity for the ampersand: &
.
In this case, you DON'T need to encode it. Try this one:
<xmp> html < < </xmp>
I'm not sure about cross browsers support, but works on IE7,FF3,Chrome3
The html code for < is <
That is, type < is &lt;
.
If you have access to server side scripting capabilities, you might be able to use utility functions of that platform. For example, in PHP you might use the htmlentities
function to your advantage:
echo htmlentities("The html code for < is <");
You could use a <pre> < </pre>
sequence
You need to encode it. For example, '<' = '<'
Here is the list.
So in your case it will end up like this:
The html code for < is & l t ;