How to put elements next to each other horizontally

I have this div for the top of my page. Nested into it, I have a
heading and another div. How can I make that heading and div stand
next to each other horizontally?
I have tried turning them into inline elements, but always one appear
in the top and the other in the bottom of it. I have used floats,
unsuccessfully.
The home page of Inkscape - http://inkscape.org/ - sets a heading
next to a div just the way I want it. I have looked into their CSS
file and tried to do the same, however, I think my knowledge is too
limited at this moment. Could anyone explain me how to do that?
Not sure if it works, but I have this example of the HTML I am using.

<body>
<div id="all">

<h1>Heading</h1>

<div id="right">
<p>Paragraph</p>
</div>

</div>
</body>
cristian [ Mo, 26 November 2007 05:01 ] [ ID #1879431 ]

Re: How to put elements next to each other horizontally

In article
<a97fecb1-fd8b-4dd9-b073-5c664c418081 [at] o42g2000hsc.googlegroups.co
m>,
Cristian <crisjunc [at] gmail.com> wrote:

> I have this div for the top of my page. Nested into it, I have a
> heading and another div. How can I make that heading and div stand
> next to each other horizontally?
> I have tried turning them into inline elements, but always one appear
> in the top and the other in the bottom of it. I have used floats,
> unsuccessfully.
> The home page of Inkscape - http://inkscape.org/ - sets a heading
> next to a div just the way I want it. I have looked into their CSS
> file and tried to do the same, however, I think my knowledge is too
> limited at this moment. Could anyone explain me how to do that?
> Not sure if it works, but I have this example of the HTML I am using.
>
> <body>
> <div id="all">
>
> <h1>Heading</h1>
>
> <div id="right">
> <p>Paragraph</p>
> </div>
>
> </div>
> </body>

Is this the sort of effect you want:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Title</title>
<style type="text/css" media="all">
p {margin-left: 10em; font-size: 1em;}
h1 {float:left; width: 5em; font-size: 2em;}
</style>
</head>
<body>
<h1>Heading</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Pellentesque augue.Suspendisse consectetuer velit nec neque. Duis
nec orci quis nulla egestas fermentum.Ut quis eros. Aenean at
augue vitae quam posuere vehicula. Pellentesque habitantmorbi
tristique senectus et netus et malesuada fames ac turpis egestas.
Maecenas justonunc, porta sed, molestie eget, adipiscing id,
ante. Cum sociis natoque penatibus etmagnis dis parturient
montes, nascetur ridiculus mus. Suspendisse potenti. Nunc
blanditmagna id odio sodales luctus. Nulla quam magna, viverra
quis, dignissim blandit, viverra nec, odio.</p>
</body>
</html>

?

There are some nice issues here.

--
dorayme
dorayme [ Mo, 26 November 2007 05:26 ] [ ID #1879432 ]

Re: How to put elements next to each other horizontally

On Nov 26, 4:01 am, Cristian <crisj... [at] gmail.com> wrote:
> I have this div for the top of my page. Nested into it, I have a
> heading and another div. How can I make that heading and div stand
> next to each other horizontally?
> I have tried turning them into inline elements, but always one appear
> in the top and the other in the bottom of it. I have used floats,
> unsuccessfully.
> The home page of Inkscape -http://inkscape.org/- sets a heading
> next to a div just the way I want it. I have looked into their CSS
> file and tried to do the same, however, I think my knowledge is too
> limited at this moment. Could anyone explain me how to do that?
> Not sure if it works, but I have this example of the HTML I am using.
>
> <body>
> <div id="all">
>
> <h1>Heading</h1>
>
> <div id="right">
> <p>Paragraph</p>
> </div>
>
> </div>
> </body>

Give the h1 and #right widths and try floating them (if you fail to
give proper widths, the elements won't float). Example css.
<style type="text/css">
<!--
#all h1 {
width: 40%;
float: left;
}
#all #right {
width: 40%;
float: left;
}
//-->
</style>
Kailash Nadh [ Mo, 26 November 2007 22:24 ] [ ID #1879469 ]

Re: How to put elements next to each other horizontally

"kailash nadh" <kailash.nadh [at] gmail.com> wrote in message
news:99f3637a-c5c7-49a6-96dd-6a86b489e6a6 [at] s6g2000prc.googleg roups.com...
> On Nov 26, 4:01 am, Cristian <crisj... [at] gmail.com> wrote:

> Give the h1 and #right widths and try floating them (if you fail to
> give proper widths, the elements won't float).

Nope. They will float. If you fail to give them width the the width defaults
to auto and the used value is the "shrink-to-fit" width.

--
Richard.
rf [ Mo, 26 November 2007 23:38 ] [ ID #1879479 ]
Miscellaneous » alt.html » How to put elements next to each other horizontally

Vorheriges Thema: Using unusual fonts
Nächstes Thema: Show layer and disable clicking other body elements