Welcome to WebmasterWorld Guest from 23.23.46.20

Forum Moderators: not2easy

Block level elements on same line

   
2:50 am on Sep 25, 2009 (gmt 0)

5+ Year Member



Hi
Are all block elements that are side by side - next to each other or on same line - or columns- floated or is there another way to do this? I use the web developer toolbar Outline block elements and there are many block level elements on same line on many web sites.
Thanks
3:58 am on Sep 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The practicality depends upon what is happening with the entire page. Other options - yes. Better or equal choices - maybe. One possible option follows. Three columns, defined widths, position: absolute:, very fluid.....

A row of inline-block: would be another possible option, but you would have to keep an especially close eye on IE.

<!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" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
html, body {
margin: 0; padding: 0; font-size: 100%;
}

#center-wrapper {
position: relative;
}

#first, #second, #third {
width: 30%;
border: .1em solid #000;
}

#first {
position: absolute; top: 0; left: 0;
}

#second {
position: absolute; top: 0; left: 50%; margin-left: -15%;
}

#third {
position: absolute; top: 0; right: 0;
}

</style>
</head>
<body>
<div id="center-wrapper">
<div id="first">
FIRST BLOCK
<br />
FIRST BLOCK
<br />
FIRST BLOCK
<br />
FIRST BLOCK
<br />
</div>
<div id="second">
SECOND BLOCK
<br />
SECOND BLOCK
<br />
SECOND BLOCK
<br />
SECOND BLOCK
<br />
</div>
<div id="third">
THRID BLOCK
<br />
THRID BLOCK
<br />
THRID BLOCK
<br />
THRID BLOCK
<br />
</div>
</div>
<!--##########

-->
</body>
</html>

8:14 am on Sep 25, 2009 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Are all block elements that are side by side - next to each other or on same line - or columns- floated or is there another way to do this?

There are probably half a dozen ways to get blocks next to one another:

- floats, although I often feel it's a bit over-used.
- absolute positioning: you can put them *anywhere*, hence also next to one another
- relative positioning: you can nudge elements to move to where you want them
- inline-blocks: they are blocks but they are also inline elements
- display: table-* : makes your elements act as if they are elements in a table.
- CSS3 multiple columns
- ... (did I miss any)?

Which is best will depend a lot on what's in them and around them.

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month