Arrange the <li> elements in a horizontal row at the bottom of the page

Is there a way to align my list items horizontally without using CSS in HTML?

Additionally, I would like the li items to appear below the image at the bottom of the page.

I've experimented with different attributes and searched extensively, but nothing seems to work.

<div style="background-color:black; margin-top:0px">
    <a href="http://csc2.madonna.edu/~brabahy/hw5/mercury2.html"><img src="http://csc2.madonna.edu/~brabahy/hw5/images/Mercury1.jpg" style="float:left; margin-right:10px" height="400" width="400"></a>
    <p style="color:brown">Mercury is the smallest planet, and it's closest to the Sun of the eight planets in the Solar System. It has an orbital period of about 88 Earth days.</p>
</div>

<br><br><br><br>

<div>
    <ul style="list-style:none">
        <li style="text-align:left"><a href="http://csc2.madonna.edu/~brabahy/hw5/museum.html"><p style="color:blue">Previous room</p></a>
        <li style="text-align:right"><a href="http://csc2.madonna.edu/~brabahy/hw5/venus1.html"><p style="color:blue">Next room</p></a>
    </ul>
</div>

Answer №1

To enhance the appearance of your li element, apply this style attribute:

style="text-align:left;float:left;display:inline-block;"

Be sure to include the following properties:

float:left and display:inline-block

Answer №2

Modify

<li style="text-align:left">

so that it reads

<li style="float:left">

in order to display the list items next to each other.

Answer №3

I want to arrange my list items next to each other in a horizontal line.

To achieve this, apply the following style: display: inline-block on the li elements.

In addition, I am aiming to have the list items positioned below an image (at the bottom of the page).

You can accomplish this by using the style:

position: fixed; left: 0; bottom: 0; width: 100%;
on the parent div element.

(See a live example here)

<div style="position: fixed; left: 0; bottom: 0; width: 100%;">
    <ul style="list-style:none;">
        <li style="text-align:left; display: inline-block;">
            <a href="http://csc2.madonna.edu/~brabahy/hw5/museum.html">
                <p style="color:blue">Previous room</p>
            </a>
        </li>
        <li style="text-align:right; display: inline-block;">
            <a href="http://csc2.madonna.edu/~brabahy/hw5/venus1.html">
                <p style="color:blue">Next room</p>
            </a>
        </li>
    </ul>
</div>

Answer №4

Is it something similar to this https://jsfiddle.net/3v8j0xf1/?

Modified

<div style="background-color:black; margin-top:0px">...

changed to

<div style="background-color:black; margin-top:0px; float: left;">...

and list items (li's)

<li style="text-align:left">...
<li style="text-align:right">...

to

<li style="text-align:left; float: left;">...
<li style="text-align:right; float: left; margin-left: 20px;">

Answer №5

To have list items display side by side, you typically need to use CSS. However, I noticed that you are utilizing inline CSS, which suggests that external CSS may not be an option for you.

Here is my suggestion addressing both aspects of your query. I have also eliminated the paragraph tags inside the list items as they are not recommended in that context.

<div style="background-color:black; margin-top:0px">
    <a href="http://csc2.madonna.edu/~brabahy/hw5/mercury2.html"><img src="http://csc2.madonna.edu/~brabahy/hw5/images/Mercury1.jpg" style="float:left; margin-right:10px" height="400" width="400"></a>
    <p style="color:brown">Mercury is the smallest planet and the closest to the Sun among the eight planets in our Solar System. It completes an orbit approximately every 88 Earth days.</p>
</div>

<div style="clear:both">
    <ul style="list-style:none;padding:0">
        <li style="text-align:left;display:inline-block;width:50%;color:blue"><a href="http://csc2.madonna.edu/~brabahy/hw5/museum.html">Previous room</a></li>
        <li style="text-align:right;display:inline-block;width:50%;color:blue"><a href="http://csc2.madonna.edu/~brabahy/hw5/venus1.html">Next room</a></li>
    </ul>
</div>

Answer №6

To enhance the wrapper div, I have included bottom:0; position:absolute. Additionally, ensure to incorporate float:left; to the li elements.

<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
</head>
<body>
<div style="background-color:black; margin-top:0px">
    <a href="http://csc2.madonna.edu/~brabahy/hw5/mercury2.html"><img src="http://csc2.madonna.edu/~brabahy/hw5/images/Mercury1.jpg" style="float:left; margin-right:10px" height="400" width="400"></a>
    <p style="color:brown">Mercury is the smallest planet, and it's closest to the Sun of the eight planets in the Solar System. It has an orbital period of about 88 Earth days.</p>
</div>

<br><br><br><br>

<div style="bottom: 0px; position: absolute;">
    <ul style="list-style:none">
        <li style="text-align: right; float: left; margin-right: 10px;">
            <a href="http://csc2.madonna.edu/~brabahy/hw5/museum.html"><p style="color:blue">Previous room</p></a>
        </li>
        <li style="text-align: right; float: left; margin-right: 10px;">
            <a href="http://csc2.madonna.edu/~brabahy/hw5/venus1.html"><p style="color:blue">Next room</p></a>
        </li>
    </ul>
</div>
</body>
</html>

You might want to consider removing the
tags for a cleaner look.

For a visual representation, check out the FIDDLE DEMO - https://jsfiddle.net/npralhad/3masxfkL/

Answer №7

If you're unsure about the specific design you're aiming for, consider using inline-block on the list items as others have suggested. I've also incorporated a % width to the image for some responsiveness and to enforce the line break.

<div style="background-color:black; margin-top:0px">
  <a href="http://csc2.madonna.edu/~brabahy/hw5/mercury2.html"><img src="http://csc2.madonna.edu/~brabahy/hw5/images/Mercury1.jpg" alt="" style="float:left; margin-right:10px; height:auto; width:100%;" /></a>
  <p style="color:brown">Mercury is the smallest planet, and it's closest to the Sun of the eight planets in the Solar System. It has an orbital period of about 88 Earth days.</p>
</div>
<br/>
<div style="position:relative; bottom:0;">
  <ul style="list-style:none">
    <li style="display:inline-block;"><a href="http://csc2.madonna.edu/~brabahy/hw5/museum.html"><p style="margin:0; color:blue">Previous room</p></a>
    <li style="display:inline-block; margin-left:3em;"><a href="http://csc2.madonna.edu/~brabahy/hw5/venus1.html"><p style="color:blue">Next room</p></a>
  </ul>
</div>

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

Retrieve JSON data from Form Submission

While I am not a front end developer, I have been trying my hand at it recently. I hope that the community here can assist me with an issue I am facing. I have a form that is supposed to send files to a server-side API like shown below: <form id="uploa ...

Show angular variable data in a table based on their index

I have an array of angular variables with values like [ 170, 1, 130, 3, 134, 4.... and so on]. I would like to present these values in a table format where the even positioned values are shown in one column and the odd positioned values in another column. ...

PHP allows for easy looping through an array based on certain conditions. By incorporating

Can anyone assist me in creating an HTML div using an array loop? Here is how my array looks: $myarray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]; This is the structure of my PHP file: <?php foreach ($myarray as $arr) { // ...

Firefox does not support CSS transitions

I've put in a lot of effort and even tried searching on Google, but I'm unable to find a solution to my problem: To help you understand my issue better, I have created a jsfiddle with my source code: Click here to view my Source Code Although e ...

Tips for preserving the dimensions of a container even after adding text dynamically

I have created a form and implemented a JavaScript warning for when the entered passwords do not match. However, I am facing an issue where adding the warning text causes other elements in the container to shift. Is there a way to prevent this from happe ...

Ensure that all `thead th` elements remain in a fixed/sticky position when using a data

I am facing an issue with my data table requirement. I need to have 2 thead elements in the table, both of which should stick when scrolling. However, only the last thead's tr stays stuck at the top while the first one gets hidden. Can anyone help me ...

Creating a visually appealing layout with rows of images of varying heights to ensure consistent spacing between text

As part of my Photo Library project, I am designing a display page that showcases four key attributes of each photo - File Name, Title, Date Taken, and Photographer Name. Additionally, there will be a preview thumbnail of the photo itself. While I aim for ...

The background image's fadeInOut transitions create a strange phenomenon where all the text appears in white

So, here's a strange issue I'm facing. On my website, the background image changes with a smooth fadeIn/Out transition. Video: Website in action: Here is the HTML markup: <div class="fondo" onclick="descargar(2,500);descargar(1,500);"> ...

Animate CSS during page load

Currently, I am implementing AJAX to dynamically load pages on my website. During the loading process, I wish to incorporate a spinning animation on the logo to indicate that content is being fetched. The jQuery script (although I'm still learning an ...

Steady Content of a Parallax Webpage

Hey there! I recently put together this awesome site and I'm facing a challenge with fixing text on the first slide, specifically the one featuring the Nike basketball. Right now, the text 'The first of its kind' is part of the background im ...

Creating a Mobile-friendly Sidebar: A Guide to Angular 5

I've been seeing a lot of recommendations online about using Angular Material for creating a sidebar, but I'm hesitant to install an entire library just for one component. After following the instructions provided here, I managed to develop a si ...

Changing the Size of a Div Element in Internet Explorer 6

I'm currently encountering issues with running this code in IE version 6. While it performs as expected in IE 7, IE 8, FireFox, and Google Chrome, I face a problem where the message at the bottom of the SurroundingWrapper div does not stay fixed to th ...

Problems Arising from Center Aligning a Horizontal Navigation Menu

I have attempted various methods to shift the navigation bar as a whole, but I am facing a roadblock. The container for the navigation bar needs to adjust its size based on the size of the navigation bar. Since the number of links will change periodically, ...

Having performance issues with an HTML5/JavaScript game on Internet Explorer 8

A new game has been developed using html/javascript. Due to confidentiality reasons, the code cannot be fully shared. The game runs smoothly on most browsers except for IE, which poses a challenge. Compatibility with IE8 is essential, despite its limitati ...

When the background image URL is altered, the button size automatically adjusts

Presently, I am working with a button <input id="fireAction" type="button" class="submit" onclick="disableSubmit('preFlight');"><br> Afterwards, I modify the background image of the button under different circumstances For example ...

Unable to establish socket.io connection on the client side

I'm struggling to connect to socket.io on the client side. While investigating the issue, I came across various script notations: <script src="socket.io.js"></script> <script src="/socket-lib/socket.io.js"></script> <script ...

What is the best way to assign a different set of sub tabs to each individual tab?

Upon hovering over MTH025-ENG111, I would like it to become visible. Any additional tips or tools you have to assist me with this are greatly appreciated. <html> <head> <title> join the club </title> </ ...

Display the input in the text box before making a selection from the dropdown menu

Latest Technologies: $(document).ready(function(){ $('#userID').change(function(){ $('#username').val($('#userID option:selected').data('username')); }); }); Coding in HTML: <select class="form- ...

Problem with CSS multi-level dropdown navigation in a vertical layout

I am in the process of creating a navigation menu with dropdown menus, which are working correctly. Now, I would like to add another sub-menu drop down inside dropdown 1, but I am having trouble getting it to function properly. How can I make Sub Menu 1 ac ...

What is the best way to use CSS to center two blocks with space in between them?

My goal is to achieve a specific design: I want two text blocks with some space in between them aligned around the midline of the page (refer to the image). I have experimented with the float property, as well as used margin and padding to create the gap ...