Log in

View Full Version : table width



kpw
06-07-2007, 02:37 PM
when i start to put text or images into a table, the width of the columns starts to change so i end up with some wide and some narrow columns, how do i make all the coluns a specific width?

thanks

Veronica
06-07-2007, 03:35 PM
Table cells will expand to fit the content unless you set them to have a specific width. To set a width, add to the cells:

<td style="width:150px;">

Or you could give each cell a class, and set the width for that class with css.

But tables really shouldn't be used for layout. Try to learn about divs and css for layout. It will make for a more flexible page.

kpw
06-07-2007, 04:35 PM
i'm not using the table for the whole site layout, it is a table with photos and links in which is displayed on the site using an iframe, so i'm not sure how to do this with divs, but if you have any suggestions i'll be happy to consider something new.

also whilst on the subject of div's, how do you set an absolute position for them, i have set the left and top properties for the div, and it appears in the right position in dreamweaver, but when i preview it in firefox, it just shows in the top left of the page. any suggestions?

thanks

Veronica
06-07-2007, 07:56 PM
An absolute-positioned element is positioned according to its containing block. If there's no containing div, the position is set according to the browser window. So this

#the_div {position:absolute; top:0; left:0;}

would put the_div at the very top and left of the screen, regardless of other content..

If the_div was inside another div, it will be positioned according to that containing div. So if the_div was inside another div called "container", it would be positioned at the top and left of "container".

kpw
06-07-2007, 08:27 PM
the div i'm having trouble with is just on the page, not in another div, it has a top property of 100 and a left property of 500, but it still appears in the top left corner of the page when i preview it, any suggestions why this might be, i'm confused by this one.


EDIT
i've tried this on an existing page which i have to see if it does the same, but not quite. rather than putting the div in the top left corner, it is aligning it to the left hand side of the page, but putting it between other peices of content depending on where i insert the code into the html editor. does this make a difference?

thanks

Veronica
06-07-2007, 08:31 PM
Can you post a link?

kpw
06-07-2007, 08:59 PM
sorry, i don't have a link, i have attached a copy of the file though. as i can't upload html, i had to alter the file extension, so change it back from .doc to .html and hopefully it will be ok to check.

1055

thanks

Veronica
06-07-2007, 10:08 PM
It's your doctype. Try this:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

kpw
06-07-2007, 11:53 PM
That works well, thank you very much