Website Beginner for wanna be web designers

    


Formatting HTML Tables

When Size Matters
Let's talk about tables and sizing

Tables can be sized two ways: by using pixels or by percentage. Sometimes we mix the two, but you have to be careful, or you might get some whacked out (unpredictable) results. Sometimes you won't want to specify a width, so that particular cell can remain fluid, stretching to fit.

When you want to specify the width of a table, you put width=" " in your table tag, with the number or percentage you want between the quotation marks.

For example <table width="300"> means that our table will be 300 pixels wide. Add the height info to that same table and a border attribute and voila...we've got:

<table width="300" height="30" border="1">

Wow, this stuff is kinda easy.


Aligning Cell Contents

See how the text in the table above is over to the left? That's the default alignment. You can also center it, force it to the right or left, or justify it using <div></div> tags.

Below are examples with the corresponding HTML to the right.

Look ma, my text is centered
<td>
<div align="center">Look ma, my text is <b>centered</b></div>
</td>
Look, I'm aligned to the right
<td width="132">
<div align="right">Look, I'm aligned to the <b>right</b>
</div>
</td>
I'm justified which can look crappy depending on the space, but if it looks right, go for it.
<td><div align="justify">
I'm <b>justified</b> which can look crappy, but if it looks right, go for it.
</div>
</td>

Notice how some of the text in this table squishes up to the edges?

We're going to fix that right now with cellpadding and cellspacing...



If you'd like us to alert you when new tutorials arrive,
join our email list (on the menu to the left)

You can email us at
Sorry, no individual questions answered,
though we may use yours as the basis for a new article.

©2007 www.WebsiteBeginner.com

 



Basic HTML Stuff

Tables
Text & Fonts
Web Graphics
Web Page Design
CSS & SSI
Web Hosting & Domains
Search Engines & How To Make Money With Your Website

Our Book Store
Home

Tell a friend
about this site!


Join our email list for
article alerts and news.


Subscribe
Unsubscribe



Your email will not be
shared with anyone
and is ONLY for
use by this site.


Questions? Comments?