Created a New Tool to Encode Sample HTML for Display
I added a new script to the “Tools” section yesterday, which should be of interest to anyone that authors a website about HTML.
I’m sure we’ve all faced this problem at one point or another - how do we get sample HTML to display properly, without being rendered, so that users can view it? Moreover, what’s the best method of doing this?
I first struggled with this when I was writing for another site (Associated Content). Because they filtered out a lot of html tags, it was pretty tough to find a way to get it to display properly. The only method I could get to work reliably was to pad the tags with spaces, like < html >.
Not the best method, but thankfully there are better ways to do it on your own site.
The basic trick is to convert all of your < characters into < and > characters into >. Want to go do all that by hand?
I didn’t think so. I tend to do it by hand if I’m just typing one or two tags, but for a full-fledged example it’s much easier to have a script do the work for you. So I built a tool to do just that.
Head over to the HTML Encoding Form, copy and paste your sample code into one textarea, and press submit. The HTML will be escaped for you, at which point you can copy and paste it back into your tutorial.







Leave a Reply