dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Mess with css div

  1. #1
    Join Date
    May 2013
    Posts
    2

    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
    <body>
    <div id="mydiv">
    <h1>Welcome!</h1>
    </div>
    </body>
    CSS
    #mydiv
    {
    padding-top:0px;
    background-color:red;
    border-radius:0px;
    width:400px;
    margin:auto;
    border: 0px solid black;
    }
    Thanks for reply

  2. #2
    Join Date
    May 2013
    Posts
    2
    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

  3. #3
    Join Date
    Sep 2008
    Location
    Dallas
    Posts
    154
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles