/    Sign up×
Community /Pin to ProfileBookmark

Mess with css div

Hi I’m new to forum so hopefully posting to correct category .

I just need help with my issue with css div . If I add 1px of padding or 1px border it add at least 10px on div height .
Concrete example here

HTML

[QUOTE]

<body>
<div id=”mydiv”>
<h1>Welcome!</h1>

</div>
</body>

[/QUOTE]

CSS

[QUOTE]

#mydiv
{
padding-top:0px;
background-color:red;

border-radius:0px;
width:400px;
margin:auto;
border: 0px solid black;
}

[/QUOTE]

Thanks for reply

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@NiBi18authorMay 21.2013 — when I use normal text , div is wrapped around and padding is working properly but if I use h1 text with no border or padding it's wrapped around until I add 1px padding or border then it is about 10px
Copy linkTweet thisAlerts:
@JavaboeyMay 29.2013 — Not sure I really understand the question, but header tags have default padding. So if you want your header tag to have 0 padding, then you have to spec 0 padding. Also, when you do have something with a zero measure, don't use "px", "em", etc. Just put 0, e.g. padding: 0; - not padding: 0px;. It's not "wrong", per se. It will still work, but semantically, you don't use the measurements when something is just 0.
×

Success!

Help @NiBi18 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...