Page 1 of 1

problem with <pre> tag not aligning text

Posted: Wed Apr 13, 2005 1:06 pm
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

Posted: Wed Apr 13, 2005 2:20 pm
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());

Posted: Wed Apr 13, 2005 4:21 pm
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