What's new
HTML Forums | An HTML and CSS Coding Community

Welcome to HTMLForums; home of web development discussion! Please sign in or register your free account to get involved. Once registered you will be able to connect with other members, send and receive private messages, reply to topics and create your very own. Our registration process is hassle-free and takes no time at all!

How to format Table Cols

jPaul

New member
Hi Everybody,

I'm trying to create a table and need to format each column a little differently:

<table>
<tr>
<td> Col-1 </td>
<td> Col-2 </td>
</tr>
</table>

I want to align the text in Col-1 to the RIGHT, and set the background-color to a HEX-color.
I want to align the text in Col-2 to the LEFT, and set the background-color to a different HEX-color.

I hope to include these alterations in a PHP statement:

<?PHP
print "<tr><td>Your USER name is: </td><td>$uName</td></tr>\n";
print "<tr><td>Your eMAIL address is: </td><td>$uPassword</td></tr>\n";
?>

Am I on the right track? How can I include a [text-align: right] and [background-color: #cc0000] to the <td> tags?

Many Thanks,
Paul
 
Hello this is Gulshan Negi
Yes, you are on a right track. If you want to apply different styles to each column in your table, you can use HTML and CSS. Here's an example of how you can modify your code to include the desired text alignment and background color:

print "<tr><td style='text-align: right; background-color: #cc0000;'>Your USER name is: </td><td>$uName</td></tr>\n";
print "<tr><td style='text-align: left; background-color: #00cc00;'>Your eMAIL address is: </td><td>$uPassword</td></tr>\n";

I hope you are now clear.
Thanks
 
Thank you, Mr. Negi

I do understand your suggestion. Thank you for taking some of your time to respond to me.
I am on a better track now.
 
Back
Top