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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:10:46+00:00 2026-05-28T06:10:46+00:00

I am trying to put a list inside of a <div> so that I

  • 0

I am trying to put a list inside of a <div> so that I can change the background of the div and make the list be a navbar.

The problem is that the items in the list actually appear in a horizontal row below the div. I don’t know why this is – they are child elements and should float to the left of each other inside the <ul> element which is inside the <div>, or at least that’s my understanding of it.

When I remove float: left, they work fine, but appear in list format instead of side by side like I want.

Why is this occuring?

Here is the PHP code that creates the HTML.

echo <<<_HDOC
    <div id="header">
        Title
    </div>

    <div id="linkbar">
        <ul id="links">
_HDOC;

if ($_COOKIE['main'] == "")
    echo  "<li class='menulinks'>Register</li>  <li class='menulinks'>Login</li>";
else{
    $cookieparts = explode('&', $_COOKIE['main']);
    echo "<li class='menulinks'>Welcome $cookieparts[0]</li>  <li class='menulinks'>Logout</li>";
}

echo "<li class='menulinks'>About</li>  </ul></div>";

And here is the CSS code

#linkbar{
        padding: 5px;
        background-color: #31574A;
        color: white;
    }

#links{
        width: 100%;
        list-style-type: none;
    }

.menulinks{
        float: left;
        padding: 10px;
    }
  • 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-28T06:10:47+00:00Added an answer on May 28, 2026 at 6:10 am

    You need to add a clear to at the end of the list.

    Why do I have to do this?

    A container element’s height does not automatically adjust to a child element that is floated. When something is floated, it is removed from the traditional flow. In order to resolve it, you must use a clear

    Example:

    CSS

    li 
    {
       float: left;
    } 
    .clearFix
    {
       clear: both;
    }
    

    HTML

    <div class="container">
        <ul>
          <li>1</li>
          <li>2</li>
          <li>3</li>
        </ul>
        <div class="clearFix"></div>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to put some custom list adapters into their own classes to make
Im trying to make a textarea where you put in a list of things,
I'm trying to build an XML file that reads the content to put inside
I am trying to make a firefox extension that will list all the videos
I'm trying to put objects inside a movie clip that will be masked allowing
Hello everyone I've been trying to put some objects in an ASP.NET list box
Trying to put a regex expression together that returns the string between _ and
I trying to put together an Android app that will take a picture and
I am trying to change the color of links inside <li> elements by setting
I'm trying to make a layout that is something similar to how the android

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.