SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : HTML and CSS :

Previous DiscussionNext Discussion
 why ?!?

<html>
<head>
<style type="text/css">
p { background-color:green; }
h1 { background-color:blue; }
div { background-color:red; }
</style>
</head>

<body>
<div>
<h1> h1 blue </h1>
<p> p green </p>
</div>
</body>

</html>

the questions:
* why the red color appear in the middle only ?
* why not the red color appear from the four sides ?
What is the rule applied ?

Than you very much

Started By nada on Nov 27, 2010 at 8:03:00 AM

2 Response(s) | Reply

Earlier Replies | Replies 1 to 2 of 2 | Later Replies
Monte on Nov 28, 2010 at 4:25:02 AM (# 1)

H1 is "inline", whereas P is a "block level" element.

The DIV is also a "block level" element.

All three rules are applied. They are simply applied based on the element they are in. Put borders around your elements to see what's going on.

And check out www.w3c.com for CSS tutorials. They will help you much more than I can.


MHenke on Nov 29, 2010 at 3:20:46 AM (# 2)

H1 is also block-level. 8)

The red "in the middle" are the default margins (bottom/top) of the H1- resp. DIV-element. You see no red on left/right because there're no default margins.
Try to set the margin to 0 and you'll see no red at all.


Earlier Replies | Replies 1 to 2 of 2 | Later Replies

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.