...

View Full Version : Strict DTD



skylis
04-13-2011, 01:17 PM
<table width="70%" align="center" id="Table1">
<tr><td><img src = "nwlogo.jpg" width="120" height="60" alt=""/></td>
<td><h3>Student Information</h3></td></tr>
</table>
<form id ="frmStudentInfo" action="ignore">
<table align="center">


I am attempting to use XHTML Strict DTD and was wondering if anyone knew what could be used instead of the align="center" for the image and then for the table align because it is not allowed under Strict.

bullant
04-13-2011, 01:26 PM
One option


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title></title>
<style type="text/css">
#Table1 {
margin: 0px auto 0px auto;
}
#imgCell {
width: 120px;
margin: 0px auto 0px auto;
}
</style>
<script type="text/javascript"></script>
</head>
<body>
<table width="70%" id="Table1" border="1">
<tr>
<td>
<div id="imgCell"><img src = "pic1.jpg" width="120" height="60" alt=""/></div>
</td>
<td><h3>Student Information</h3></td>
</tr>
</table>
</body>
</html>

kansel
04-13-2011, 05:50 PM
Another option (replace this style rule in Bullant's code):


#imgCell {
text-align: center;
}

bullant
04-14-2011, 12:45 AM
Yes that is another option and it works but imo it is not semantically correct because the image is not text.

It's a bit like putting a table in a div and applying text-align: center to the div to center the table. Although it will center the table, imo it's not semantically correct because the table is not text either.

skylis
04-14-2011, 01:06 AM
Thanks Bullant for your help so far. I have managed to work it down to 1 error before passing Strict DTD. I know that "name" is no longer used and I read that "id" can be put in it's place but when I do that the form stops working. Any idea what I could use in the place of "name"?


<form name ="frmStudentInfo" action="ignore">

bullant
04-14-2011, 01:57 AM
I know that "name" is no longer used and I read that "id" can be put in it's place but when I do that the form stops working. Any idea what I could use in the place of "name"?


<form name ="frmStudentInfo" action="ignore">

Yes, form names are not allowed in xhtml. They are in html afaik.

I normally code in xhtml strict as well.

All you need to do is change the way you reference a form in your javascript. You have 2 options afaik.

1) give the form an id



<form id="frmStudentInfo" action="">

<script type="text/javascript">

oForm = document.getElementById('frmStudentInfo');

</script>

2) use the "default" DOM form reference. All forms on a web page are stored in an array called forms in the DOM. The first form will be in forms[0], a second form will be in forms[1] etc.

So to get the entered text in a textbox with a name="txtUsername" you could do


var username = document.forms[0].txtUsername.value;or another option


oForm = document.forms[0];
var username = oForm.txtUsername.value;

skylis
04-14-2011, 02:13 AM
Works perfectly. Thank you very much for your help. Still getting used to the Strict DTD so it has taken a while for me to catch onto all of it.

bullant
04-14-2011, 02:32 AM
no problem :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum