News:

LVCS.NET offers low cost domain registration services.

Main Menu

how to show source code in an html document???

Started by Paris, March 30, 2006, 01:55:33 AM

Previous topic - Next topic

Paris

Can someone please tell me if there is a certain attribute i can use to show code snippets or large sections of code on my site? Like on forums you can use [ c o d e ] [ / c o d e] to show code. I tried using <code>TEXT HERE</code>and also <pre>TEXT HERE</pre> but neither work like i want them to.

Please help soon, thanx.

dest

paste your code that you want displayed into notepad. Use replace to change the following

< to &lt;
> to &gt;

Put the code on the page where you want it, and it will not be read as html.
meh :P

GP™

Also, If your using a automated service such as a forum (PHP ONLY) you can use this:
//Pulls Message From Textarea On Submit
$message = $_POST['message'];

// Replaces < With &lt;
$message = str_replace("<", "&lt;", $message);

// Replaces > With &gt;
$message = str_replace(">", "&gt;", $message)



Paris


zz4

Not sure desire...



To make simple html visible on a web page   <xmp></xmp>   ???

webzone (archived)

QuoteTo make simple html visible on a web page   <xmp></xmp>

xmp is a deprecated tag and should not be used anymore.

zz4

Bad Thinking but if browsers still digest it?



I have not tried XMP in a long time.


Where's there a list of no-no stuff? (for education)


Was not <br> going obsolete?

webzone (archived)

QuoteWas not <br> going obsolete?

I don't remember anything about <br> becoming obsolete.

QuoteBad Thinking but if browsers still digest it?

I have not tried XMP in a long time.

Browsers are not obliged to support it anymore. Some may still accept it if they want to.

QuoteWhere's there a list of no-no stuff? (for education)

W3Schools has a list of HTML tags and shows which ones are deprecated.

zz4

gezzzz   I'm still using things like <center>  <font....



I guess bad practice but if the latest browsers support them......---===

LegendPro

The best way to go nowadays in coding HTML is using XHTML.  Basically its just a cleaner and stricter version of HTML.  You can learn about XHTML here... http://www.w3schools.com/xhtml/default.asp

webzone (archived)

QuoteThe best way to go nowadays in coding HTML is using XHTML.

It is important to be careful when using XHTML. This document (Sending XHTML as text/html Considered Harmful) explains the problems it can cause.

One of the major problems blocking the use of real XHTML is that Internet Explorer still doesn't support it and IE 7 won't either. To be processed as XHTML, a page must be sent with the application/xhtml+xml MIME type and IE doesn't accept that.

sixthcrusifix

Why don't you just put it in a textarea? Then you even have a scrolly box.

<textarea cols='50' rows='6'>
TEXT HERE
</textarea>

cols = colums, how wide it is (usualy a LOT more than rows)
Rows = rows, how tall it is.
Visite me website at http://www.sixthcrusifix.com