Forum Moderators: open

Message Too Old, No Replies

Horizontal Spacing Around a Nested Table

         

Fortune Hunter

9:03 pm on Aug 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a table with cells for content. The main content cell has another small nested table that is right aligned to hold some local navigation links. I am trying to place content in the main content table cell and I would like it to wrap around my small nested table of links similar to the way text flows around a picture on a page, which so far I can do with no problems. In addition, I have a CSS class on the small nested table that creates a 1 pixel border around the links (nested table).

If you want text to flow around a picture you can simply align it and then use horizontal and vertical spacing to keep your text from smashing up against the picture. Does anyone know if there is something similar I can do for my table mentioned above?

I want the small CSS border, but my text runs up against this border as it flows around the table and I would like to have about 8-10 pixel spacing around the table. I can't add another column since it then grabs the CSS border and simply moves the border out. Any ideas?

FH

Fortune Hunter

9:33 pm on Aug 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just to see what would happen I tried using the...

hspace="8"

within the table properties tags to see if it would work the same way as it does with a picture, but it doesn't, it ignores it.

FH

[edited by: Fortune_Hunter at 9:34 pm (utc) on Aug. 22, 2007]

tedster

11:52 pm on Aug 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Align attributes and hspace are now deprecated html - see this from 2002 [webmasterworld.com...]

Try using a css float:left rule for the table, and give the table some margin with css, too. You'll be creating future proof mark-up, and also have a better time with all current browsers.

Fortune Hunter

3:51 am on Aug 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In this particular issue, I found a solution, but it is not the one you mentioned. I am going to have to bone up on CSS, I use a little bit of it, but I know just enough to be dangerous. I don't use it to set up positioning and such as many people do now. I use it for font, borders, link styling, etc. The more complex CSS for table placement and stuff like that is still beyond what I use.

FH

rocknbil

7:59 am on Aug 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



F.H., as one who flies RC helicopters - breaking it is a necessary step in mastering it. Well, not crashing as often. This one's actually pretty easy - the CSS below applies to both the table version and the table-less version, with the exception that you don't need the td selector and the border-collapse style for the tableless version. The div inset is a little wider but they are basically rendering identically.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled</title>
<style type="text/css">
#main,#maindiv {
width: 400px;
margin:auto;
border-collapse: collapse;
background-color: #e4e4e4;
}
#main td, #maindiv { padding: 6px; }
#main p, #maindiv p { margin:0; padding: 0 0 6px 0; }
#nav, #navdiv {
width: 150px;
float: right;
border: 4px double #a8a8d7;
margin: 0 0 0 8px;
padding: 6px;
border-collapse: collapse;
background-color:#ffffff;
}
#nav ul,#navdiv ul { margin: 0; padding: 0; }
#nav li,#navdiv li { margin: 0; padding: 4px; list-style: none; }
</style>
</head>
<body>
<table id="main">
<tr>
<td valign="top">
<table id="nav">
<tr><td valign="top">
<ul>
<li><a href="#">Nested tables</a></li>
<li><a href="#">are very bad</a></li>
<li><a href="#">and that's all</a></li>
<li><a href="#">I'll say</a></li>
</ul>
</td>
</tr>
</table>
<p>Here we have some content. I really do miss tables.
They are so reliable and consistent. I wonder if it's some kind of
evil corporate conspiracy. Ah well.</p>
<p>Here we have some content. I really do miss tables.
They are so reliable and consistent. I wonder if it's some kind of
evil corporate conspiracy. Ah well.</p>
<p>Here we have some content. I really do miss tables.
They are so reliable and consistent. I wonder if it's some kind of
evil corporate conspiracy. Ah well.</p>
</td>
</table>
<p><strong>Now let's try that without tables:</strong></p>
<div id="maindiv">
<div id="navdiv">
<ul>
<li><a href="#">Nested tables</a></li>
<li><a href="#">are very bad</a></li>
<li><a href="#">and that's all</a></li>
<li><a href="#">I'll say</a></li>
</ul>
</div>
<p>Here we have some content. I really do miss tables.
They are so reliable and consistent. I wonder if it's some kind of
evil corporate conspiracy. Ah well.</p>
<p>Here we have some content. I really do miss tables.
They are so reliable and consistent. I wonder if it's some kind of
evil corporate conspiracy. Ah well.</p>
<p>Here we have some content. I really do miss tables.
They are so reliable and consistent. I wonder if it's some kind of
evil corporate conspiracy. Ah well.</p>
</div>
</body>
</html>

Fortune Hunter

10:26 pm on Aug 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



rocknbil:

Yes, those are similar. I am slowly getting there. Like most developers I learn a little more each day and get better than before. This is a matter of going through that process again. Thanks!

FH