473,385 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Why is the table less wide than the div when they both have the same width?

Probably something simple i'm overlooking, taking the below html and
css style settings, when you view in a browser (IE or Mozilla for
example), the table is a tiny bit less wide than the div. Yet I have
set both to the exact same width (99%) and they have the same border
settings. This also happens if i use a width like "800px".

The desired effect is that the table be just above the div as a header
and in the browser both should be the exact same width.

Thx in advance.

(Note i simplified the original html to get rid of as much as possible
that was not relevant).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
</head>
<body>
<table
style="Cursor:hand;border-width:1px;border-style:Solid;border-color:Black;background-color:#FBF5C5;width:99%;border-bottom-width:0px;">
<tr>
<td align="left"
id="ctl00_FormPlaceHolder_ExpandingPanel1_expanded grip"
style="width:1%;display:block;"><img src="/widsplus/something.gif"
width="15" height="19" alt="" /></td><td
class="greytextdarkboldlarge">More Search Options</td><td
id="ctl00_FormPlaceHolder_ExpandingPanel1_expanded chevron"
align="right" style="width:1%;display:block;"><img
src="/widsplus/something.gif" width="25" height="19" alt="" /></td>
</tr>
</table><div id="ctl00_FormPlaceHolder_ExpandingPanel1"
style="display:block;border-color:Black;border-width:1px;border-style:Solid;width:99%;">
<select name="ctl00$FormPlaceHolder$lbprioritytype">
<option selected="selected" value="=">=</option>
<option value="&lt;>">&lt;&gt;</option>
<option value="NULL">Null</option>

</select>
</div>
</body>
</html>

Jun 23 '06 #1
1 1999
Robert schreef:
Probably something simple i'm overlooking, taking the below html and
css style settings, when you view in a browser (IE or Mozilla for
example), the table is a tiny bit less wide than the div. Yet I have
set both to the exact same width (99%) and they have the same border
settings. This also happens if i use a width like "800px".


For the table, the width = the width of the table + the width of the
border
For the div, the width = the width of the div without the width of the
border
So your table with border has width = 99%
And your div with border has width = 99% + 2 pixels

I simplified your html (see below) and put the table and the div block
in it, first with border, than without. You now clearly see, that it is
the border that is the trouble.

Solution: get rid of the table. Tables are not meant to be used for
layout, they are meant to use for tabular data. If you do use them for
layout, then you run into problems like this. Use div blocks instead.
Look at the css property float for displaying divs next to each other,
like your table cells.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
</head>
<body>
<h1>With borders</h1>
<table style="border: solid 1px #000000; background-color:#FBF5C5;
width:99%; border-bottom-style: none;">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<div style="border: solid 1px #000000; width:99%; margin: 0px;
padding: 0px; background-color: red">&nbsp;</div>
<h1>Without borders</h1>
<table style="border-style: none; background-color:#FBF5C5;
width:99%">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<div style="border-style: none; width:99%; margin: 0px; padding: 0px;
background-color: red">&nbsp;</div>
</body>
</html>

Jun 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kai Grossjohann | last post by:
I have a table which contains a top-aligned table cell: .... <tr style="height:40"> ... <td colspan="1" rowspan="2" align="left" valign="top" style="overflow:hidden;">...
2
by: Stephen Weatherly | last post by:
Could anyone please help me with a problem I am having with my table widths??? If I have 2 images within a td tag, but using CSS relative positioning I position one over the top of the second (I...
28
by: Anthony Williams | last post by:
Good morning, I'm currently designing a site, using CSS, and wish to create a variable width two-column layout, with header and footer, and one fixed-width column on the left. Previously, I...
1
by: kiran | last post by:
Hi All I have 2 tables, Table1's width is specified as 100% and Table2's width as 1004px. If the page is viewed in 1024 res, both tables stretch across the window, but if the window is...
25
by: Michael Schuerig | last post by:
I'm trying to do something seemingly very simple, but it's brought me close to crushing my head on the keyboard. All I want is a table where the head row is fixed and the body columns below are...
117
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of...
2
by: Nobody | last post by:
Ok, I've got my page laid out pretty much how I want it, but can't figure out one part... my "content" area is a fixed width table with 2 columns... COL A = 600px wide & COL B = 170px wide... ...
12
by: slartybartfast | last post by:
I'm new(ish) to css, comfortable using tables, but trying real hard to move away. Please see http://84.9.125.31/developer/css_test/test5.html NB This issue is with IE & Opera - I've tried IE...
3
by: Csaba Gabor | last post by:
I have a table with 3 rows, and two pieces of data to display in each row. However, the first element of the last two rows and the 2nd element of the 1st row are very short. This would seem to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.