473,386 Members | 1,706 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,386 software developers and data experts.

Table data not centering

Hello,

I've created a table that has two rows that are span across three columns.
The third row has three columns, each with an image. The last row is also
span accross three columns. The span rows are centering their data.
however, the row with three columns, each with images (myimages1-3) are not
centering with the rest of the table. Any idea why?

Thanks in advance!

See below code:

<!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">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
width: 188px;
}
.style3
{
width: 224px;
}
.style4
{
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
.style5
{
font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1" border=0>
<TH COLSPAN=3 class="style5">The images below the greyHorizLine
are not centering<TR><TH COLSPAN=3>
<img alt="" src="images/greyHorizLine.JPG" style="width: 700
px; height: 8px" /><TR>
<TH class="style3">
<img alt="" src="images/wsconstruction/myimage1.JPG"
style="width: 125px; height: 140px; float: right;" />
<TH class="style2">
<img alt="" src="images/wsconstruction/myimage2.JPG"
style="width: 167px; height: 137px" />
<TH>
<img alt="" src="images/wsconstruction/myimage3.JPG"
style="width: 102px; height: 135px; float: left;"
/><TR>
<TH COLSPAN=3>
<img alt="" src="images/greyHorizLine.JPG" style="width:
500px; height: 8px" />
</table>

</div>
</form>
</body>
Oct 25 '08 #1
1 2262
First of all, you have sloppy html. You should have an opening and closing
<trfor every row, and quotes around all attributes (yes, even border and
colspan). Try this:

<table class="style1" border="0">
<tr>
<th colspan="3" class="style5">...</th>
</tr>
<tr>
<th colspan="3">...</th>
</tr>
<tr>
<th class="style3">...</th>
<th class="style2">...</th>
<th>...</th>
</tr>
<tr>
<th colspan="3">...</th>
</tr>
</table>

Some browsers do not like tables that do not have closing tags for tr, th,
and td. But why are you expecting your cells to be centered? You do not use
style4 in anything, which is the only style class that would center
anything. Another suggestion, although it can sometimes be a pain, is to add
an extra row at the beginning to specify the widths, because the only row
whose cell widths the browser pays attention to is the first one. You will
obviously want to add a style attribute to this row of visibility:collapse;
so that the row does not make your table look different than expected. And
this is just a personal preference, but when using CSS, I always use td
instead of th, since I am setting the styles anyway, why would I want to
worry about what different browsers like to do with the rendering of th
tags? But something that is even more important is I would suggest trying to
be more compliant with xhtml. This is not hard, the basic most common things
to note are:

1. Always have a closing tag. You can use the self-closing slash, like you
do with the <img/>, but you must do this even with tags like <br/>.

2. Only lower case is allowed for tag and attribute names.

3. You must use quotes for all attribute values.

For example, <TH COLSPAN=3 class="style5"is incorrect because of the
capitalization and missing quotes. It should be changed to <th colspan="3"
class="style5">. You should also include:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

as the first line in every page to let the browser know your code is xhtml.
It is a very simple transition to make, after a few days it will be as
automatic as the html you are doing now, but it is strongly recommended that
you make the transition. Hopefully all this helps. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"franky" <fr****@discussions.microsoft.comwrote in message
news:04**********************************@microsof t.com...
Hello,

I've created a table that has two rows that are span across three columns.
The third row has three columns, each with an image. The last row is also
span accross three columns. The span rows are centering their data.
however, the row with three columns, each with images (myimages1-3) are
not
centering with the rest of the table. Any idea why?

Thanks in advance!

See below code:

<!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">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
width: 188px;
}
.style3
{
width: 224px;
}
.style4
{
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
.style5
{
font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1" border=0>
<TH COLSPAN=3 class="style5">The images below the greyHorizLine
are not centering<TR><TH COLSPAN=3>
<img alt="" src="images/greyHorizLine.JPG" style="width:
700
px; height: 8px" /><TR>
<TH class="style3">
<img alt="" src="images/wsconstruction/myimage1.JPG"
style="width: 125px; height: 140px; float: right;" />
<TH class="style2">
<img alt="" src="images/wsconstruction/myimage2.JPG"
style="width: 167px; height: 137px" />
<TH>
<img alt="" src="images/wsconstruction/myimage3.JPG"
style="width: 102px; height: 135px; float: left;"
/><TR>
<TH COLSPAN=3>
<img alt="" src="images/greyHorizLine.JPG" style="width:
500px; height: 8px" />
</table>

</div>
</form>
</body>

Oct 25 '08 #2

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

Similar topics

10
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
47
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
2
by: autogoor | last post by:
I have a table and, in one cell of it, I have another table. How can I center the second table in the cell with css? Thanks, autogoor
1
by: Bob M. | last post by:
Is it possible to center text/data in a table in Microsoft Access. Or justify it in any way?
16
by: Tantale | last post by:
I used this serviec to check my webpage http://www.jmrw.com/Abroad/Barcelone/index.htm Made with Dreamweaver 8. The result is 206 errors, most of them "end tag omitted, but OMITTAG NO was...
9
by: Neal | last post by:
http://www.brassattackofspringfield.com/gigs.html CSS at http://www.brassattackofspringfield.com/default.css Opera and IE render caption as desired. Firefox does not. Why? And is there a fix?
7
by: SpaceMarine | last post by:
hello, i see that <table align="center"is no longer valid markup in XHTML. nor is <center><table></table></center>. how then does one center a table? found articles for centering text: ...
1
by: Jonathan N. Little | last post by:
replace Q with c Mike Copeland wrote: Tables are block elements, you center blocks of smaller width within other blocks by setting the left and right margins to "auto". You do not use...
7
by: lawpoop | last post by:
On Mar 11, 6:58 pm, Bergamot <berga...@visi.comwrote: Berg, thanks for taking the time to look at this. Here is the URL ( sorry for the delay in response): http://nerdcraft.net/survey.html ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.