Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:05:15+00:00 2026-06-08T08:05:15+00:00

I have a CSS like this: #sidebar { float: left; margin: 0; padding: 0;

  • 0

I have a CSS like this:

#sidebar {
   float: left;
   margin: 0;
   padding: 0;
   background: #044169;
}
#sidebar-menu {
   height: 100%;
   margin: 0;
   padding: 0;
   background: #CCCCCC;
}

(Call it test.css) and a simple HTML file like this:

<!DOCTYPE html>
<html>
<head>
   <link rel="stylesheet" href="test.css">
</head>
<body>
  <h1>Test</h1>
  <div id="sidebar">
      <div id="sidebar-menu">
          <ul>
             <li>One</li>
          </ul>
      </div>
  </div>
</body>
</html>

I really do not understand why sidebar-menu is 35px high, and sidebar is 51px wide. Shouldn’t sidebar-menu be as high as sidebar…?!?

In my head, I think: well, margins are 0, paddings are 0, so the containing element, sidebar-menu, which has height:100% (of the container, I would think), ought to be as big as the container!

I am obviously getting something very wrong…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:05:16+00:00Added an answer on June 8, 2026 at 8:05 am

    Unless otherwise specified, the parent container div will size itself appropriately to its largest element that has an absolute size, not a relative size.

    The div sidebar-menu does not have an absolute size, but determines its size from its child, the unordered list with the text “One”. It is because of this that sidebar will in fact size itself to 35px high and 51px wide, then its child sidebar-menu will fill 100% of that height and the width of its child.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSS entry that looks like this: .header { background-image: url(./images/embouchure.jpg); background-repeat:
I have a horizontal menu on a page like this <link rel=stylesheet type=text/css href=/classified/siteassets/css/mymenu.css
I have css declaration like this #first, #second, #third { font-size:1em; background: url('path/to/image') no-repeat;
For example I have a css style like this : input.validation-passed {border: 1px solid
I have a directory like this /Workspace /app app.js /lib /public /styles *.css /scripts
I have a Div layer like this ... <style type=text/css> <!-- #newImg { position:absolute;
I have a html like this: <html> <head> <link rel=stylesheet type=text/css media=all href=style.css> </head>
I have a piece of CSS like so: .formTable:nth-child(odd) { background-color: #eeb; } I
I have a simple sidebar like this: <div class=sidebar> <ul class=nav> <li class=Page1><a href=Page1.html>Page1</a></li>
If I have a structure like this: <div id=main> <div id=sidebar> <div id=tag-cloud/> </div>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.