shwekhaw
08-10-2012, 12:23 AM
Hi. I have been trying to update a site to be HTML5 compliant. Some table attributes needs to be changed to css formating to be compliant. I enjoy solving the problem myself but I have spent last 3 hours trying to figure out css code for cellpadding and spacing and this just giving me headache. I simplify the code for troubleshooting.
Here is original code with table attributes. It show up in browser fine. But if you change the Doctype to <!DOCTYPE HTML>, the layout all screwed up.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
.MenuBorder {
BACKGROUND-COLOR: #000000;
}
.HeadLine {
BACKGROUND-COLOR: #ADADAD;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<BODY>
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
<TR>
<TD colspan="2" class="MenuBorder"><IMG src="spacer.gif" width="1" height="1" border="0"></TD>
</TR>
<TR>
<TD class="HeadLine" height="22">
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
Menu1 | Menu2 | Menu3 | Menu4 ................
</TABLE>
</TD>
</TR>
<TR>
<TD colspan="2" class="MenuBorder"><IMG src="spacer.gif" width="1" height="1" border="0"></TD>
</TR>
</TABLE>
</body>
</html>
Here is the code I come up with after reading a lot into CSS. And it still does not work.
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
table.space {
border-collapse : collapse;
width:100%;
}
.MenuBorder {
BACKGROUND-COLOR: #000000;
padding:0px;
width:100%;
}
.HeadLine {
BACKGROUND-COLOR: #ADADAD;
padding:0px;
width:100%;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<BODY>
<TABLE class="space">
<TR>
<TD colspan="2" class="MenuBorder"><IMG src="spacer.gif" width="1" height="1" border="0"></TD>
</TR>
<TR>
<TD class="HeadLine" height="22">
<TABLE class="space">
Menu1 | Menu2 | Menu3 | Menu4 ................
</TABLE>
</TD>
</TR>
<TR>
<TD colspan="2" class="MenuBorder"><IMG src="spacer.gif" width="1" height="1" border="0"></TD>
</TR>
</TABLE>
</body>
</html>
Please check for me what I am doing wrong here. The image spacer is 1x1 pixel (attached). It is not showing up as border line but as thick cells on top and bottom of menu bar.
Here is original code with table attributes. It show up in browser fine. But if you change the Doctype to <!DOCTYPE HTML>, the layout all screwed up.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
.MenuBorder {
BACKGROUND-COLOR: #000000;
}
.HeadLine {
BACKGROUND-COLOR: #ADADAD;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<BODY>
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
<TR>
<TD colspan="2" class="MenuBorder"><IMG src="spacer.gif" width="1" height="1" border="0"></TD>
</TR>
<TR>
<TD class="HeadLine" height="22">
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
Menu1 | Menu2 | Menu3 | Menu4 ................
</TABLE>
</TD>
</TR>
<TR>
<TD colspan="2" class="MenuBorder"><IMG src="spacer.gif" width="1" height="1" border="0"></TD>
</TR>
</TABLE>
</body>
</html>
Here is the code I come up with after reading a lot into CSS. And it still does not work.
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
table.space {
border-collapse : collapse;
width:100%;
}
.MenuBorder {
BACKGROUND-COLOR: #000000;
padding:0px;
width:100%;
}
.HeadLine {
BACKGROUND-COLOR: #ADADAD;
padding:0px;
width:100%;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<BODY>
<TABLE class="space">
<TR>
<TD colspan="2" class="MenuBorder"><IMG src="spacer.gif" width="1" height="1" border="0"></TD>
</TR>
<TR>
<TD class="HeadLine" height="22">
<TABLE class="space">
Menu1 | Menu2 | Menu3 | Menu4 ................
</TABLE>
</TD>
</TR>
<TR>
<TD colspan="2" class="MenuBorder"><IMG src="spacer.gif" width="1" height="1" border="0"></TD>
</TR>
</TABLE>
</body>
</html>
Please check for me what I am doing wrong here. The image spacer is 1x1 pixel (attached). It is not showing up as border line but as thick cells on top and bottom of menu bar.