Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Dec 2013
    Location
    Were my backpack is!
    Posts
    19
    Thanks
    3
    Thanked 0 Times in 0 Posts

    question about sizes and box model

    Hi.

    If I set an element to have a margine and padding of 0 and no border, and then set the height of that element to 100%, should that not cover the page top to bottom?

    Now this is true if I set its position to absolute, but that is not possible as I have a sidebar. However when set to relative, with a top position of 0, there is white space on the top and bottom of my block element. I don't understand why there should be a difference, as the only element in the flow before the block is a sidebar that is sharing the horizontal space with the block.

    I can move the block up, but then the white space on the bottom grows.

    Thanks,
    -Adrian

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,302
    Thanks
    10
    Thanked 283 Times in 282 Posts
    You'd have to show us code, but I suspect a padding on the body or html element is getting in your way. Have you set those to 0 also from their default values?

  • Users who have thanked tracknut for this post:

    Adrian888 (01-01-2014)

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello Adrian888,
    Looking at the site you link to in another question it looks like you are seeing the default 8px margin on the body of your document.
    Add this bit to your CSS to remove it -
    body {margin: 0;}
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • Users who have thanked Excavator for this post:

    Adrian888 (01-01-2014)

  • #4
    New Coder
    Join Date
    Dec 2013
    Location
    Were my backpack is!
    Posts
    19
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks! I had no idea body has margins and stuff!
    Anything else like that I should know about.

  • #5
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,302
    Thanks
    10
    Thanked 283 Times in 282 Posts
    Quote Originally Posted by Adrian888 View Post
    Anything else like that I should know about.
    Not the body specifically, but virtually every html tag has default margins, sizes, etc. You might not think of it, but they're there, and the different browser vendors can have their different settings for them. Think of <p> - you expect a certain amount of space between paragraphs, a bit more than a non paragraph line spacing. That's done with a margin setting that the browser vendor has provided for you, so that you don't have to do it.

    There's a "browser reset" idea, that you can include in your CSS to specifically set all html tags all the same, or as Excavator suggested, you can set your own values for specific tags. That's the option I choose as well, set those specific ones where I know I'll have a problem, and address others if and when they come up.


  •  

    Posting Permissions

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