Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

table-less css table

Status
Not open for further replies.

KnotGoblin

Technical User
Jan 4, 2005
77
US
I've been, let's say, challenged to consider a new paradigm in webpage layout. So I'm trying to create a table without a table element. I'm just trying to get the feel of dealing wil flow and placement.

So part of my question is: How do i create the float affect while keeping the div's contained in the the outer div while maitaining the ability to have dynamic amounts of content?
How do I put more that one div on a line?

Here's what i've got so far:
Where do i go know?

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]

<html>
<head>
	<style>
		#container
		{
			border: solid 1px #996699;
			width: 500px;
			min-height: 200px;
		}

		#header
		{
			background-color: #0000bb; 
			width: 500px;
			height: 75px;
		}

		#menu
		{
			background-color: #669966;
			height: 200px;
			width: 100px;
		}

		#contents
		{
			background-color: #bb0000;
			height: 500px;
			width: 400px;
		}

		#footer
		{
			background-color: #00bb00;
			width: 500px;
			height: 50px;
		}
	</style>
</head>
<body>
	<div id="container">
		<div id="header">
		</div>
		<div id="menu">
		</div>
		<div id="contents">
		</div>
		<div id="footer"
	</div>
</body>
</html>

Sorry for the super noob post.

-Jer
 
KnotGoblin said:
So I'm trying to create a table without a table element.
I hope you're not really trying to do that. Because it is not really smart to create something from scratch when you have an element just for that. Tables and css can be used together. Of course, if you are creating a layout without tables, that is an entirely different matter.

KnotGoblin said:
So part of my question is: How do i create the float affect while keeping the div's contained in the the outer div while maitaining the ability to have dynamic amounts of content?
How do I put more that one div on a line?
Very much like you said. Use property [tt]float[/tt] on the div. Floating elements (left or right) will stack them up next to each other within their container, providing there is enough room for all of them (note that there must be enough of room for width, borders, padding and margin). If there isn't enough room, the element that does not fit anymore will drop below, wherever is the highest place it can still fit -- if your floated elements have different widths and heights.

Only one thing to be careful about is the clear element. Floated elements are taken out of document flow and will not expand their container height-wise. To achieve this expansion, an element must follow all floated elements that clears from floating -- has a property [tt]clear: both;[/tt] for example.

Come back if you have further concerns after all this.
 
well, from what i'm told, this forum will agree that a table is "bad practice" in page layout.
So I'm trying to create a table without a table element.
I guess the that was a bad way to put it.

Of course, if you are creating a layout without tables
yes, correct.

but anyway the clear: both; is what i was looking for that fixed it.

thanks

-Jer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top