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 7516001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:59:33+00:00 2026-05-30T00:59:33+00:00

I am designing a top bar for a website and cannot figure out how

  • 0

I am designing a top bar for a website and cannot figure out how to force the <a> elements below have the same height as the parent <li> elements. The code below shows the <li> elements with a green background and the <a> elements with a yellow background. I would like to have the yellow boxes span the whole height of the green boxes. Setting the height of the <a> elements to 100% doesn’t do trick. What am I missing?

<!DOCTYPE html>
<head>
  <style>
    div#topbar {
      width: 100%;
      height: 30px;
      top: 0;
      border: 1px solid black;
    }   
    #topbar ul {
      margin: 0;
      padding: 0;
      list-style: none;
      line-height: 30px;
    }
    #topbar ul li {
      margin: 0;
      padding: 0 10px;
      background-color: green;
      display: inline;
      float: left;
    }
    #topbar a {
      background-color: yellow;
    }
  </style>
</head>
<body>
  <div id="topbar">
    <ul>
      <li><a href="">Item 1</a></li>
      <li><a href="">Item 2</a></li>
    </ul>
  </div>
</body>
  • 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-05-30T00:59:35+00:00Added an answer on May 30, 2026 at 12:59 am

    Its because tag is an inline element and it doesn’t take height into account so you need make it block which can be made by various methods but most suitable in your case is ‘float’.

        div#topbar {
      width: 100%;
      height: 30px;
      top: 0;
      border: 1px solid black;
    }   
    #topbar ul {
      margin: 0;
      padding: 0;
      list-style: none;
      line-height: 30px;
    }
    #topbar ul li {
      margin: 0;
      padding: 0 10px;
      background-color: green;
      display: inline;
      float: left;
    }
    #topbar a {
      background-color: yellow;
      float:left; /*add this*/
    }
    

    http://jsfiddle.net/YMPe2/

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

Sidebar

Related Questions

I am designing a website and I want to have a static menu at
I have a tool bar at the top and bottom of my application and
I have a YUI menu top bar navigation menu based from this example .
I am designing my first website. I have designed a button image in gimp
When designing user table what would be the must have fields from the security/user
I'm designing a fairly simple web site but as I don't have much experience
I have some preoblems when it comes to designing a view, As you can
Are there any Web page designing software out there that allow me to drag
Often when I'm designing a site, I have a need for a specific style
Alright, I am designing a website using XHTML 1.0 Strict and CSS 1,2,3. And,

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.