saravanan shanmugavel
saravanan shanmugavel

Reputation: 69

extra space around div

I have a problem here i am getting space around this text i was not able to get rid off. i cannot apply globally padding:0 or margin:0 to the all divs. My div is part of the page i want to remove extra space around my div alone i cannot apply padding:0 or margin:0 to body also.

<html>
<body>
<div class="topcont" id="topcont" style="display: block;padding:0px;margin:0px">
<div  id="dragcont" style="display: block;padding:0px;margin:0px">
    <div style="padding:0px;margin:0px; text-align: center; font-size: 18px; font-weight: bold; font-family: Helvetica Neue;">
        Drop up to 5 photos here
    </div>
    <div style="padding:0px;margin:0px; font-size: 18px; font-family: Helvetica Neue; border: 0px none; height: 18px; text-align: center;">
        Or
    </div>
</div>
<div style="padding:0px;margin:0px;color:#333; text-align:center; font-size:14px;font-family:Helvetica Neue">
   to add them as attachments
</div>
</div>
</body>
</html>

I dont know why i am getting space above the given texts.

Upvotes: 0

Views: 5791

Answers (3)

Tom
Tom

Reputation: 311

http://jsfiddle.net/sCj6y/1/ here you go but you should not style elements in the HTML file.

Upvotes: 0

CodeTalk
CodeTalk

Reputation: 3667

You can easily set margins to 0 using the following on any element.

#myDiv{
margin:0px;
}

Note the 0px; and not 0;

For rendering/optimization purposes its good to include the unit of measurement (e.g. px,em,etc)

Upvotes: 1

AronVietti
AronVietti

Reputation: 379

You need to set the margins to 0 for the elements that border it, depending on the rest of the layout possibly for the relevant directions only.

Upvotes: 0

Related Questions