views:

164

answers:

6

How to print "html" tag ( including '<' and '>' also) tag using html without using text areas and javascipt also

+21  A: 

Use HTML character references:

&lt;html&gt;

Should output

<html>
driis
+5  A: 

Try doing:

&lt;html&gt;
RedFilter
+2  A: 

If you want to display <html> literally, use reference to represent the tag open delimiter < and the tag close delimiter >, for example:

&lt;html&gt;

This will then be displayed as:

<html>

Gumbo
+2  A: 

do this

&lt;html&gt;
Daniel Moura
A: 

What you can easily do is grab the contents of a page (etc) and then escape the HTML its entities.

Say this little two lines of php will get example.com code and print it out as HTML.

<pre>
  <?php
    $file = file_get_contents('http://www.example.com');
    echo htmlentities($file);
  ?>
</pre>

htmlentities - Convert all applicable characters to HTML entities

Frankie
This isn't related to the question.
xintron
@xintron: Jagan asked how to do it without using text-areas or javascript. My answer explains what are HTML character entity references and also gives a little code snippet so the user understands there are already functions in place than can do this for him.
Frankie
@Frankie: Your answer requires a computer with PHP available. Your answer explains briefly how to convert a string with HTML-characters to HTML entities. This wasn't what Jagan asked for. He/She wanted a simple answer explaining about HTML-entities and how to use them to produce what he/she needs. A list with common HTML-entities might have been more appropriate (ie. http://www.w3schools.com/tags/ref_entities.asp )
xintron
+2  A: 

Special characters in HTML, such as '<', '>', '"' and '&' can be printed using the following format:

&name;

where name would be replaced by a character name. The most common would then be

&lt;   =   <    (less than)
&gt;   =   >    (greater than)
&amp;  =   &    (ampersand)
&quot; =   "    (double quote)

So to write <html> you would write in HTML:

&lt;html&gt;
Frxstrem