Jump to content
Larry Ullman's Book Forums

Recommended Posts

I have an HTML question. Wasn't sure where else to put it, so I'm posting it here.

 

Anyway, this might sound like a silly question, but I want to be able to literally display HTML entities on an HTML page. For example, I want to be able display < on an HTML page instead of <. Does anyone know how to do this?

 

Thank you.

Link to comment
Share on other sites

It's not something I've ever had to do but this works:

 

echo htmlspecialchars(htmlspecialchars('&'));

 

OR

 

echo htmlspecialchars('&');

 

There might be another way but like I said never had to do it before.

Link to comment
Share on other sites

A little CSS-hacking perhaps?

 

HTML:
&<span class="hide">.</span>lt;

CSS:
span.hide {
  display: none;
  // possibly more code.
}

 

< will always be encoded to < by the browser I think. This method might work because it's split up by punctuation. :)

 

Not tested though

 

Edit:

 

If the text does not need to be markable by mouse/etc, you might just use a picture?

Link to comment
Share on other sites

Hmmm...okay. Thanks for the ideas. I wonder if I could enter an HTML comment in between an entity code or something.

 

I scoured the Net, and could not find any definitive answer. I kept looking at the source code for sites using <, but it's not obvious.

 

Well, I'll keep looking. And if nothing else, Antonio's idea works.

Link to comment
Share on other sites

 Share

×
×
  • Create New...