3777635804 babcd16f90 m Three Ways to Display Sample Html in a Web Browser
by iStylr

Three Ways to Display Sample Html in a Web Browser

If you’re looking to write about web design and HTML, you’ve no doubt run into this problem. How do you display sample mark-up that the user can see?

The problem is simple. You want to display the sample markup. The user’s browser wants to render it as actual mark up. You need to come up with something to tell the browser – “Hey, this isn’t supposed to be rendered!”

There are a few ways to do this.

First, you could use an xmp tag.

The xmp tag was developed for displaying “example” HTML. Once the browser sees an xmp tag, it stops rendering all HTML until it sees a closing tag.

However, the tag is deprecated. It’s no longer included in the HTML standards – which will prevent your site from validating – and it may not be supported by all browsers. Use at your own risk.

A second, more reliable method, is to include the markup in a textarea box.

When you create a textarea element, you can include text in between the opening and closing tags as “default” text. Any HTML in this text remains unrendered – which allows you to easily display your sample markup.

There are two problems with this, though. First, you can’t include a closing textarea tag within your example – or it will prematurely close the textarea that you are using to display your example. You also cannot style the text at all with css.

The third solution – probably the best – is to escape all of the signs in the sample code.

If you replace

This is by far the surest method of displaying your sample HTML, the only problem is that you need to escape all of the characters. However, you can take a shorcut – use this form to do the escaping for you.

Copy and paste your own code in, and the escaped code will be created on the spot.

I’m the author of Web Cash – a blog about web design, writing, and making cash on the net. You can read more about How to Display Sample HTML, or check out the latest HTML Tutorials.

A PHP and HTML Tutorial in which we processes information from a form using the $_POST[]; functions in PHP and created a table and form. Link for Notepad2: www.flos-freeware.ch
Video Rating: 4 / 5