problem with <pre> tag not aligning text

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
thallish
Forum Commoner
Posts: 60
Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark

problem with <pre> tag not aligning text

Post by thallish »

hey all

I'm currently playing around with the idea of making my own box where source code is shown. I am using it for smaller code snippets.

The page is:


http://www.thallish.dk/php_mysql_connect.php


As you can see the text in the code box is not aligning left? And that annoys me big time!

my CSS code for that particular class is

Code: Select all

pre.code{

 white-space: pre;
 color: #000000;
 background-color: #999999;

 padding-right: 2px;
 padding-left: 2px;
 padding-bottom: 2px;
 padding-top: 2px;
 font: 8pt Courier, monospace;
 width: 100%;

 overflow: scroll;
 overflow: auto;

 }
Can anybody help me please? And if this is not the best way to do don't be afraid to say so :wink:

/thallish
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

He he he... I wont laugh cos it's easily done :-)

Look at your HTML source... the text is all indented and <pre> is therefore doing it's job very affectively ;-)

By the way... I think you should look into highlight_string() and highlight_file()... this will make the job easier and PHP code look far prettier (like in this forum) ;-)

Code: Select all

$server 	= &quote;hostname&quote;;	// the servername 	
						$user	 	= &quote;root&quote;;			// username			
						$password = &quote;password&quote;;	// server password	
						$database = &quote;database&quote;;	// name of database	
						
						$db = mysql_connect($server, $user, $password) or die(&quote;Couldn't connect to database&quote; . mysql_error());
						
						$connection = mysql_select_db($database,$db) or die(&quote;Couldn't connect to database&quote; . mysql_error());
thallish
Forum Commoner
Posts: 60
Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark

Post by thallish »

hey

thank you for the reply

I finally got to the same conclusion as you with the whitespace by playing around a little. But thanks anyway. and i'll look in on the functions you posted :wink:

regards

thallish
Post Reply