/    Sign up×
Community /Pin to ProfileBookmark

I have a table that displays database records. It worked fine until I added a <div> tag above the <table> code.

Here is my page in IE:
[img]http://vivxdesign.com/Shareaza/mozbug2.jpg[/img]

…and here it is in Firefox 1.0 Final
[img]http://vivxdesign.com/Shareaza/mozbug1.jpg[/img]

Has anyone ever seen anything like this before? Usually, IE is the one I have trouble with. ?

Here is the relavent code:

[code=php]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<title>Database Records – Project H.O.P.E – Groups</title>
<link rel=”stylesheet” type=”text/css” href=”style.css” />
</head>

<body>
<form id=’formAction’ name=’formAction’>

<p>
<div class=’functions’>
<center>Project H.O.P.E. Database</center>
<input type=’button’ value=’Delete’ onclick=’deleteRecords()’ />
<input type=’button’ value=’Email’ onclick=’emailPeople()’ />
</div></p>

<p>
<table style=”display:block;border:1px solid black;margin:1px;position:relative;” border=”0″ cellspacing=”3″ cellpadding=”0″ align=”center”>
<tr>

<td align=”center” bgcolor=”#D7FFD7″ height=”40″ valign=”top”>
<div style=”clear:both”><strong>All</strong><br /><input type=’checkbox’ onchange=’checkAll()’ id=’allCheck’ /></div>
</td>

<td align=”center” bgcolor=”#D7FFD7″ height=”40″ valign=”top”>
<div style=”clear:both”><strong>ID<br />(<a href=”?ID=on&field=ID&order=asc”>+</a>/<a href=”?ID=on&field=ID&order=desc”>-</a>)</strong></div>
</td>

</tr>

<tr>

<td bgcolor=”#EFE0E0″ align=”center” height=”40″ valign=”middle”><div style=”clear:both”><input type=’checkbox’ value=’7′ /></div>
</td>
<td bgcolor=”#EFE0E0″>7
</td>

</tr>

<tr>

<td bgcolor=”#D9DAFF” align=”center” height=”40″ valign=”middle”><div style=”clear:both”><input type=’checkbox’ value=’11’ /></div>
</td>
<td bgcolor=”#D9DAFF”>11</td>

</tr>

</table>
</p>

<p>

<div class=’functions’>
<input type=’button’ value=’Delete’ onclick=’deleteRecords()’ />
<input type=’button’ value=’Email’ onclick=’emailPeople()’ />
</div>

</p>

<input type=’hidden’ id=’numRecs’ value=’2′ /></form>

</body>
</html>
[/code]

[code=php]
/*Contents of style.css*/
.functions{
float:left;
border-color:#0000FF;
border-style:solid;
border-width:1px;
padding:1px;
margin:1px;
background-color:#D9DAFF;
width:100%;
height:auto;
text-align:left;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:24px;
color:#fefeff;
font-weight:900;
position:relative;
}
body {
color:#333;
background-image: url(“images/silverStripe.jpg”);
margin:20px;
padding:0px;
font:11px verdana, arial, helvetica, sans-serif;
}
[/code]

It looks like to me that instead of the table respecting is relative positon, it renders at the coordinate (20,20) because the body’s padding is set to 20px. That doesn’t explain why the table is off to the right though.

Any help would be appreciated. ?

to post a comment
CSS

10 Comments(s)

Copy linkTweet thisAlerts:
@BonRougeDec 16.2004 — [URL=http://validator.w3.org/check?verbose=1&uri=http%3A//cheers-sendai.com/test/mercury7.htm]Start here.[/URL]
Copy linkTweet thisAlerts:
@FangDec 16.2004 — Too much CSS and HTML
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <br/>
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;title&gt;Database Records - Project H.O.P.E - Groups&lt;/title&gt;
&lt;style type="text/css"&gt;
&lt;!--
body {
color:#333;
background-image: url("images/silverStripe.jpg");
margin:20px;
padding:0px;
font:11px verdana, arial, helvetica, sans-serif;
}
h1 {
margin:0.2em;
text-align:center;
font-size:250%;
}
.functions{
border-color:#0000FF;
border-style:solid;
border-width:1px;
padding:1px;
margin:1px;
background-color:#D9DAFF;
font-family:Verdana, Arial, Helvetica, sans-serif;
color:#fefeff;
font-weight:900;
}
--&gt;
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form id='formAction' name='formAction'&gt;

&lt;div class='functions'&gt;
&lt;h1&gt;Project H.O.P.E. Database&lt;/h1&gt;
&lt;input type='button' value='Delete' onclick='deleteRecords()' /&gt;
&lt;input type='button' value='Email' onclick='emailPeople()' /&gt;
&lt;/div&gt;

&lt;table style="border:1px solid black;margin:1.5em auto;" cellspacing="3" cellpadding="0"&gt;
&lt;tr&gt;

&lt;td bgcolor="#D7FFD7" height="40" valign="top"&gt;
&lt;strong&gt;All&lt;/strong&gt;&lt;br /&gt;&lt;input type='checkbox' onchange='checkAll()' id='allCheck' /&gt;
&lt;/td&gt;

&lt;td bgcolor="#D7FFD7" height="40" valign="top"&gt;
&lt;strong&gt;ID&lt;br /&gt;(&lt;a href="?ID=on&amp;field=ID&amp;order=asc"&gt;+&lt;/a&gt;/&lt;a href="?ID=on&amp;field=ID&amp;order=desc"&gt;-&lt;/a&gt; )&lt;/strong&gt;
&lt;/td&gt;

&lt;/tr&gt;

&lt;tr&gt;

&lt;td bgcolor="#EFE0E0" height="40" valign="middle"&gt;&lt;input type='checkbox' value='7' /&gt;
&lt;/td&gt;
&lt;td bgcolor="#EFE0E0"&gt;7
&lt;/td&gt;

&lt;/tr&gt;

&lt;tr&gt;

&lt;td bgcolor="#D9DAFF" height="40" valign="middle"&gt;&lt;input type='checkbox' value='11' /&gt;
&lt;/td&gt;
&lt;td bgcolor="#D9DAFF"&gt;11&lt;/td&gt;

&lt;/tr&gt;

&lt;/table&gt;

&lt;div class='functions'&gt;
&lt;input type='button' value='Delete' onclick='deleteRecords()' /&gt;
&lt;input type='button' value='Email' onclick='emailPeople()' /&gt;
&lt;/div&gt;


&lt;input type='hidden' id='numRecs' value='2' /&gt;&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;

and as [B]BonRouge[/B] wrote, you still need to [URL=http://validator.w3.org/]validate[/URL]
Copy linkTweet thisAlerts:
@mercury7authorDec 16.2004 — Thanks for the help gentlemen!

I removed all the aligns, and took out the <p> around <div> elements. I also removed some of the uneccessary <div>'s, and made the title an <h1>. An, I fixed the style sheet a bit to suit my needs.

I'm not sure what did it, but displays perfectly on both Firefox and IE now.

After reading the tutorial in BonRouge's sig, I also realize I'm gonna have to change the way I do a few things.

-No <b>ed and <br>eakfast tags

-<p> around all multiple lines of text

-no more aligns in elements (use text-align in css)

I've got a question though:

When I validate, it catches a bunch of things in my JavaScript that I know are correct. Do I need to remove my script for validation purposes?
Copy linkTweet thisAlerts:
@FangDec 16.2004 — Without seeing the page it's difficult to tell what errors are occuring.

Anyway, it is better having JavaScript and CSS in external files.
Copy linkTweet thisAlerts:
@mercury7authorDec 16.2004 — [b]Straight from the validator[/b]

From Line 14, column 16: character ";" not allowed in attribute specification list

for(i=0;i<num;i++){

&#9993;

Line 14, column 16: element "num" undefined

for(i=0;i<num;i++){

You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element), or by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead).

&#9993;

Line 19, column 16: character ";" not allowed in attribute specification list

for(i=0;i<num;i++){

&#9993;

Line 19, column 16: element "num" undefined

for(i=0;i<num;i++){

You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element), or by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead).

&#9993;

Line 27, column 65: character "&" is the first character of a delimiter but occurred as data

...tp://project-hope.us/delete_members.asp?table=groups&";

If you wish to include the "<" character in your output, you should escape it as "&lt;". Another possibility is that you forgot to close quotes in a previous tag.
[/QUOTE]

[code=php]
function checkAll(){
var num=document.getElementById("numRecs").value;
window.status=num;
if (document.getElementById('allCheck').checked==true){
for(i=0;i<num;i++){
document.forms[0].elements[i+3].checked=true;
}
}
else{
for(i=0;i<num;i++){
document.forms[0].elements[i+3].checked=false;
}
}
}
[/code]


I don't mean to put JavaScript in the CSS forum, but you sound like a good person to ask. The script above is perfectly correct, but it gets those errors in the Validator.


-------------------------------------------------

I have one more question, and this one does have to do with css. I want to have curved corners on a div, but it shows up like:

[img]http://www.vivxdesign.com/Shareaza/mozbug3.jpg[/img]



[code=php]
<div class='functions'>
<img class="fl" src="images/dtlb.jpg" />
<img class="fr" src="images/dtrb.jpg" />
<input type='button' value='Delete' onclick='deleteRecords()' />
<input type='button' value='Email' onclick='emailPeople()' />
<img class="fl" src="images/dblb.jpg" />
<img class="fr" src="images/dbrb.jpg" />
</div>
[/code]

[code=php]
.functions{
padding:0px;
margin:0px;
background-color:#D9DAFF;
font-family:Verdana, Arial, Helvetica, sans-serif;
color:#fefeff;
font-weight:900;
text-align:left;
}
.fl{
float:left;
margin:0px;
}
.fr{
float:right;
margin:0px;
}
[/code]


Why does the <div> close itself early?
Copy linkTweet thisAlerts:
@FangDec 16.2004 — I need a live page link to see what's happening with the validation.

CSS: after using [i]float[/i] you usually need a [i]clear[/i] after it.

<div class='functions'>

<img class="fl" src="images/dtlb.jpg" />

<img class="fr" src="images/dtrb.jpg" />

<input type='button' value='Delete' onclick='deleteRecords()' />

<input type='button' value='Email' onclick='emailPeople()' />

<img class="fl" src="images/dblb.jpg" />

<img class="fr" src="images/dbrb.jpg" />

[COLOR=green]<div style="clear:both;"></div>[/COLOR]

</div>
Copy linkTweet thisAlerts:
@mercury7authorDec 16.2004 — Ok, here's a duplicate of my page:

I added an empty <div> as you suggested, but the results are not pretty. ? (In IE, theres a big box underneath the two floats, and in Firefox it looks the same as before.)

http://www.project-hope.us/test.asp?All=on
Copy linkTweet thisAlerts:
@FangDec 17.2004 — Here's the solution to the rounded corners:
&lt;div class="functions"&gt;
&lt;img class="fl" src="testasp_files/dtlb.jpg" /&gt;
&lt;img class="fr" src="testasp_files/dtrb.jpg" /&gt;
&lt;h1 class="center"&gt;Project H.O.P.E. Database&lt;/h1&gt;
&lt;input value="Delete" onclick="deleteRecords()" type="button" /&gt;
&lt;input value="Email" onclick="emailPeople()" type="button" /&gt;
&lt;div style="border-bottom:1px solid #fff;"&gt;
&lt;img class="fl" src="testasp_files/dblb.jpg" /&gt;
&lt;img class="fr" src="testasp_files/dbrb.jpg" /&gt;
&lt;div style="clear: both;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

The same solution applies to the bottom section.

Validator errors:

There is more to serving your document as xhtml than just changing the DTD.

The way to avoid the problem with JavaScript is to use external files.

Also read:

http://www.w3.org/TR/xhtml1/#guidelines

http://www.w3.org/MarkUp/2004/xhtml-faq

http://www.yourhtmlsource.com/accessibility/xhtmlexplained.html

http://keystonewebsites.com/articles/mime_type.php
Copy linkTweet thisAlerts:
@mercury7authorDec 17.2004 — Thanks for all the help, Fang!

[URL=http://vivxdesign.com/Shareaza/mozbug4.jpg]Here's[/URL] what it ended up looking like.

I'm definately going to read through that information you provided me, as I am always looking to expand my understanding.

Thanks again,

Ben
Copy linkTweet thisAlerts:
@mercury7authorDec 21.2004 — After reading http://www.yourhtmlsource.com/accessibility/xhtmlexplained.html, I found this
Ampersands in URLs

Ampersand characters are frequently used in page addresses to carry variables, like in PHP. When coding these addresses into your XHTML, you must escape them using the entity value [b]&amp;amp;[/b]. They'll be displayed as ampersand characters (&) on screen, of course.
[code=php]
<a href="reviews.php?page=27&style=blue">link</a>
becomes
<a href="reviews.php?page=27&amp;amp;style=blue">link</a>
[/code]

[/quote]


That means that my JavaScript variable must change from
[code=php]
location="http://www.whatever.com?all=on&blue=on"
to
location="http://www.whatever.com?all=on&amp;amp;blue=on"[/code]


Just thought I'd post stuff here that I didn't know. I've been "in the game" for a while, and there are still things I'm learning.
×

Success!

Help @mercury7 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...