What is the best way to show two horizontal unordered lists side by side?

I am currently working on a project to replicate the layout of the Google homepage using HTML. The main challenge I am facing is with the footer section, specifically in displaying two separate lists of links aligned differently on the same line. Despite numerous attempts, I have not been able to accomplish both tasks at once:

  1. Creating two lists: one aligned left and the other right
  2. Displaying both lists on the same line

Here is an excerpt from my current HTML file focusing on the code within the footer tag:

<!DOCTYPE html>
<html>
...

</footer>   
</body>


</html>

The CSS styling relevant to this issue is as follows:

ul{
    list-style-type: none;
    margin: 0;
    padding: 0; 
    text-align: right;
}

...

Answer №1

To create a unique layout for your lists, consider using the float property in CSS.

<ul class="left">
<li>One</li>
<li>Two</li>
</ul>
<ul class="right">
<li>Three</li>
<li>Four</li>
</ul>

You can style it with this CSS:

li {display:inline-block}
.left {float:left}
.right {float:right}

For a live example, check out this JSFiddle link.

Answer №2

The best way to achieve this is by placing each of your Unordered lists into two separate div containers.

For example:

<div style="float:left; width:50%;">
      <ul style="Display:inline-block;">
       <li>1</li>
       <li>2</li>
      </ul>
</div>
<div style="float:right; width:50%;">
       <ul style="Display:inline-block;">
       <li>1</li>
       <li>2</li>
       </ul>
 </div>

If the container is wrapping onto the next line, it may be due to margins. In this case, try reducing the width percentage or eliminating the margins.

Answer №3

To enhance the layout, consider grouping the lists in separate divs within your 'bottomlist' section and eliminate classes from the <ul> and <li> elements. Here's an example:

<div class="bottomlist">
         <div class="left">
        <ul>
             <li><a>Catalog</a></li>
             <li><a>Products</a></li>
             <li><a>Services</a></li>

                        </ul>
        </div>

        <div class="right">
        <ul>
             <li><a>Support</a></li>
             <li><a>Contact</a></li>
             <li><a>Feedback</a></li>
                        </ul>
</div>
</div>

You can style it with CSS as follows:

#bottomsection .left { 
display: block;
position: relative;
float:left;
width: 50%;
}

#bottomsection .right { 
display: block;
position: relative;
float:right;
width: 50%;
}

Don't forget to adjust margins/padding for adequate spacing between the lists.

Answer №4

<ul id="menu">
<li><a href="#logo">First Item Entry</a></li>
<li><a href="#logo">Second Item Entry</a></li>
</ul>


#menu{
padding:2px;
margin:2px; 
color:#fff; 
font-family: arial, helvetica, sans-serif; 
white-space:nowrap; 
list-style-type:none; 
} 
#menu li {
display:inline-block;
}
#menu li a {
padding:0.2em 1em;
background:#fc6;
color:#000;
text-decoration:none; 
float:left;
border:1px solid #000; 
}
#menu li a:hover{
background:#08c;
color:#fff;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Overlap in Bootstrap 4 Sections

I'm facing an issue with two sections on my website. They are properly separated until a certain size, https://i.sstatic.net/e52t2.png, but when the size is reduced, they start to overlap https://i.sstatic.net/aMtHr.png. Below is a snippet of my code: ...

Utilizing Rvest for extracting data from LinkedIn profiles

I've been trying to scrape my LinkedIn profile using Rvest, but I encountered a problem in the experience section. The XPath below was supposed to retrieve the experience section, but it's returning 0 nodes: Test <- read %>% html_nodes(xpa ...

CSS - image does not adhere to max-height when placed in a fluid container - link to jsFiddle

For instance: http://jsfiddle.net/vjqjv/7/ I am facing an issue with an image inside a container (refer to #slider-section in the jsFiddle) that has a fluid height and a set max-height. I have defined max-height and max-width for my image as 100% (check ...

Stop the text from wrapping to the full width of its parent when it overflows onto the following line

When I shrink the width in responsive design, the text overflows to the next line and the text wrapper expands to fit the parent container. Is there a way to prevent this behavior so that it looks like the red container? I could add padding to the contain ...

Eliminate HTML tags when CKEDITOR is switched

I recently switched from a normal textarea to CKEDITOR, with a toggle button that allows users to switch between the two. However, I encountered an issue where HTML tags are not removed after destroying CKEDITOR if there was existing content in it when swi ...

Tips for concealing non-selected categories in the product tree when a single category is chosen

When navigating through the shopping cart, users will encounter a product category tree structured as follows: Category1 Subcategory11 Subcategory12 ... Category2 Subcategory21 Subcategory22 ... Category3 Subcategory31 Subcategory32 ... ...

Validating phone numbers with regular expressions in Java

I recently started learning Java and Regex, and I'm currently facing a challenge with phone number validations. The task at hand is to create simple phone number validations. I already have an input field in my HTML code that has the attribute type=" ...

Start the CSS3 animation in reverse right away

I am trying to achieve a "flashing" effect by adding the .shown class to my #overlay, causing the opacity to fade in for 2 seconds and then immediately reverse, fading out for another 2 seconds. After experimenting with removing the class, I found that it ...

Attempting to change the background color of a table row when hovering in React, but experiencing no success

Describing the appearance of my table row: <tr onMouseEnter={() => {this.buttonIsHovered = true} } onMouseLeave={() => {this.buttonIsHovered = false}} className={this.buttonIsHovered ? 'hover' : null}> The initial value ...

What is the process for linking a specific HTML file to a URL?

After preparing all my HTML, CSS, and JS files for upload to a server (I am using cPanel which I have experience with), I found myself wondering how to assign a specific HTML file to a custom link, such as "devwebdevelopment.com/about" I am looking to cre ...

How to use the zip iterable to create multiple rows in a table using ReactJS

I have a collection of arrays that I need to unpack and insert into a table. For instance, I will have an array named a=[1,2,3,4] and b=['a','b','c','d'], both with the same length. Initially, I have a table with o ...

Media query failing to adjust properly

On my website's "about" page, I'm attempting to implement a media query but encountering an issue. In the original CSS, I structured the "information" section into 2 columns with right padding to prevent the content from extending all the way to ...

Require assistance with setting a marker for location tracking

Can someone assist me in developing a geo-location marker? Here is the code snippet I am currently using: var latLong = response._source.misc.latLong; console.log(latLong); var getaddress = response._source.misc.address; showPosition(latLong ...

The combination of Google Maps and CSS transforms causes a blur effect on the page

After implementing the CSS Transform technique to center a div both horizontally and vertically, the desired effect was achieved. However, an unexpected issue arose on pages that contained a Google Maps iframe causing the entire page to go blurry. To view ...

Converting Ajax to JSON with Jquery offline and Manifest for enhanced offline web applications

Looking to create an offline web application, I'm in the process of transitioning from Ajax to JSON using JQuery offline. Here is the initial Ajax code: $.ajax({ url: contentpage, data: contentpagedata, cache: false }).done(function( html ) { ...

Extracting content from concealed elements with Selenium in Python

I am currently using the Python Selenium library to scrape data from a website, but I am encountering an issue. When I click on the website to retrieve additional rows from a table, those rows appear with the classes hidden-xs hidden-sm, which makes it cha ...

What is the reason behind larger text causing content on the left to be pushed downward?

After creating four basic divs, I decided to modify the header div's properties. Here is the HTML code: <div class="third"> Lorem Ipsum </div> <div class="third"> Lorem Ipsum </div> <div ...

Filter data using dropdown in PHP PDO

Is there a way to update the datatable based on filter criteria? I am using Drop Down Search with branch ID as BID, outlet ID as OID, and user ID as UID. Below is my code snippet where I encounter an issue mentioning 'draw' not defined along with ...

Extract the URL from the query parameters and inject it into a div element

I am currently working on a project to create an ASPX page with two separate div's. The first div will have static content, while I want the content in the second div to be dynamic. Users should be able to input a URL as a query string, and that URL s ...

Problem with CSS inline-block bottom margins

How can I resolve the issue with inline-block in CSS causing a 1px whitespace? Changing word-spacing or letter-spacing does not solve the margin-bottom problem. Here are snippets from my HTML files: <!DOCTYPE html> <html lang="en> <head> ...