The styled horizontal list item has a background color that is not covering the entire

After setting up my CSS, I noticed a discrepancy in how the background color behaves when hovering over links in the navigation versus links in the footer. While the entire "button" area is filled with the background color in the nav, only the space behind the text is filled in the footer. I'm looking for a solution to ensure that the entire "button" is filled in the footer without relying on classes or images (utilizing HTML5/CSS3 as much as possible). Any ideas on how to resolve this issue?

I have tested this in multiple web browsers and suspect it might be due to the list items being displayed inline, but I haven't been able to find a solution yet.

--- Updated CSS ---

@CHARSET "UTF-8";

* {
margin: 0;
padding: 0;
}

html * {
    margin: 0;
    /*padding: 0; SELECT NOT DISPLAYED CORRECTLY IN FIREFOX */
}

/* GENERAL */

body {
    background: #fff;
    color: #333;
    font-family: verdana, "MS Trebuchet", arial, helvetica, sans-serif;
    font-size: 62.5%;
    margin: 0 auto;
    width: 960px;
}

header {
    background-color: #999;
    border: 1px solid #999;
    border-radius: 25px;
    margin-top: .5em;
}

header h1 {
    color: #fff;
    font-weight: bold;
    font-size: 2.4em;
    margin: .8em 0 .3em 0;
    text-align: center;
}

nav {
    margin: 1em 30em;
    padding: .8em 1.2em;
}

nav ul {
    padding-left: 1.5em;
    list-style: none;
}
nav ul li {
}
nav ul a {
    display: block;
    text-decoration: none;
}
nav ul li a {
    background-color: #FFF;
    border: 1px solid #999;
    border-radius: 25px;
    color: #222;
    display: block;
    font-size: 1.2em;
    font-weight: bold;
    margin-top: 5px;
    margin-bottom: 5px;
    padding: 12px 10px;
    text-align: center;
    text-decoration: none;
}
nav ul a:hover {
    color: #333;
    background: #ccc;
}

nav#baseball {
    display: none;
}
nav#football {
    display: none;
}

footer {
    border-top: 1px solid #ccc;
    margin-top: .5em;
    margin-bottom: 1em;
    padding: .8em 1.2em;
}

footer ul {
    list-style: none;
    text-align: center;
}

footer ul li { 
    border: 1px solid #999;
    border-radius: 25px;
    display: inline; 
    margin: 0.0em 1.0em 0.0em 1.0em;
    padding: 0em 1.5em 0 1.5em;
}
footer ul a {
/*    display: block; */
    text-decoration: none;
}
footer ul li a {
    color: #222;
}
footer ul a:hover {
    color: #333;
    background: #ccc;
}

--- Updated HTML ---

<header>
    <h1>Sports Fan</h1>
</header>

<nav id='sports'>
    <ul>
        <li><a href="about-temp.html">Baseball</a>
        </li>
        <li><a href="blog-temp.html">Basketball</a>
        </li>
        <li><a href="consulting-clinic-temp.html">Football</a>
        </li>
        <li><a href="contact.html">Hockey</a>
        </li>
        <li><a href="contact.html">Soccer</a>
        </li>
    </ul>
</nav>

<nav id='baseball'>
    <ul>
        <li><a href="homerun.html">Homerun</a>
        </li>
        <li><a href="bighit.html">Big Hit</a>
        </li>
        <li><a href="doubleplay.html">Double Play</a>
        </li>
        <li><a href="doubleplay.html">Bad Call</a>
        </li>
    </ul>
</nav>

<nav id='football'>
    <ul>
        <li><a href="about-temp.html">Touchdown</a>
        </li>
        <li><a href="blog-temp.html">Big Play</a>
        </li>
        <li><a href="consulting-clinic-temp.html">Sack</a>
        </li>
        <li><a href="contact.html">Interception</a>
        </li>
        <li><a href="contact.html">Bad Call</a>
        </li>
    </ul>
</nav>

<footer>
    <ul>
        <li><a href="choose.html">Choose</a>
        </li>
        <li><a href="manage.html">Manage</a>
        </li>
        <li><a href="about.html">About</a>
        </li>
    </ul>
</footer>

Answer №1

Updated the code and placed it in a jsFiddle

Here are the CSS changes made:

footer li{ display:inline }

footer ul a{ 
    border: 1px solid #999;
    border-radius: 25px;
    display: inline-block; 
    margin: 0.0em 1.0em 0.0em 1.0em;
    padding: 0em 1.5em 0 1.5em;
    text-decoration: none;
    color: #222;
}

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

Challenge with organizing space within a nested layout of flexboxes and CSS grids

Is it possible for my aside element and div.content to evenly split the available space in the container? Additionally, should the grid within div.content take up all the vertical space? The issue I'm encountering is that grid items aren't able ...

Emphasize a checkbox by selecting it when another checkbox is checked

I have a question about checkboxes and highlighting the checkmarks. The issue I am facing is that I have multiple checkboxes with the same ID for different screen resolutions. When I click on the label for "Check 1" it highlights the corresponding checkmar ...

Javascript and CSS combo for creating a stylish fade effect

Hey everyone, I have a design challenge where I need to change the color of a picture inside a box when the user hovers over it. I have four boxes like this and my goal is to make everything else fade out when a user hovers over a specific box. Anyone kn ...

Express causing textarea in http form to have empty req.body

Here is a form for users to upload a file and submit text: form(action='/createpost' enctype="multipart/form-data" method='post' id="imgForm") input(type='file' name='imgPath' size = "60") br textarea(na ...

Aligning variable width numbers within a div container

Currently experimenting with CSS to create a calendar design that mimics the look of a traditional paper calendar. One issue I've encountered is the alignment of numbers within boxes, especially when dealing with double digits. When displaying a sing ...

Steps for deactivating tab stops on the primary webpage in the presence of a snackbar

On my web page, there are multiple drop-down menus, input fields, and buttons that can be interacted with using both the tab key and mouse. After entering certain data, I trigger a snackbar (source: https://www.w3schools.com/howto/howto_js_snackbar.asp) t ...

Eliminate the header top margin in Bootstrap

HTML <div class="container-fluid"> <div class="row"> <div class="page-header header_site"> <h1><font>ABC Company</font></h1> </div> </div> </div> CSS Code: .header_site { b ...

Center alignment is not possible for the Div element

Problem Every time I attempt to implement the following code (outlined below), the div only appears centered when using width: 100px;. <div style="border: solid 1px black; width: 100px; height: 100px; background-color: blue; margin-left: auto; mar ...

Conceal the button briefly when clicked

How can I disable a button on click for a few seconds, show an image during that time, and then hide the image and display the button again? HTML: <input type="submit" value="Submit" onclick="validate();" name="myButton" id="myButton"> <img st ...

Contrasts between Flash and HTML5

Now that YouTube has transitioned from flash to HTML5, what are the unique features and functionalities of HTML5 that set it apart from flash? I am also curious to learn a more in-depth and intriguing aspect of HTML5 beyond what can be found through a sta ...

Troubleshooting border-left and td alignment problems in an HTML email displayed in Outlook 2013

Currently, I am facing a frustrating challenge while working on an HTML email signature. It seems to display perfectly in all email clients except for Outlook 2007, 2010, and 2013. The specific issue I'm encountering is with the alignment of the secon ...

Customize the Vuetify 2.0 sass variable $heading-font-family

I'm currently trying to customize the default variable $heading-font-family in Vuetify 2.0.0-beta.0, but I'm encountering issues with this particular override. Oddly enough, I have been successful in overriding other variables such as $body-font- ...

Choosing specific elements with Selenium using OR/AND operations in Python

I am encountering an issue while working with Selenium using Python. Here is a preliminary example of my code snippet. <body> <button info="content1" aria-label="1">"Click 1"</button> <button info ...

What is the best way to display just the border of a background image while hiding the content?

The demonstration at this codepen https://codepen.io/Chester/pen/QPoyjN showcases a border animation effect. While it works effectively with a white background, I am interested in making the box's background dynamic. <div class="rainbow"& ...

Customize the appearance of disabled dates in the eonasdan-datetimepicker styling

I am seeking to customize the default styles for the "eonasdan-datetimepicker" (https://github.com/Eonasdan/bootstrap-datetimepicker) by implementing a basic hover message feature. The CSS attributes currently applied to disabled dates are as follows: .bo ...

Creating an HTML form that submits data to a PHP script, which then saves the

Looking for some assistance with a PHP issue I am having. I know my way around PHP, but I wouldn't say I'm an expert. Here's the problem: I have created an HTML form (form.html) and now I want the output from formular.php to be saved as a u ...

jscrollpane does not work properly in Firefox, but it functions correctly in Chrome

I am currently utilizing jScrollpane to display a combination of images and a div in a horizontal format. While I have successfully implemented it on Chrome, it appears that Firefox is not applying the CSS correctly to prevent images from wrapping, resulti ...

Establishing the default scroll position in tables using React.js

How can I set the initial scroll in ReactJS Material-UI tables? I'm working with a table that has numerous columns and I would like to have specific columns in view automatically without having to scroll, essentially establishing an initial scroll. I ...

Steps for displaying an HTML table in Excel by clicking on a button

My goal is to open an HTML table in XLS format with a single click of a button. Currently, I have a JavaScript function that allows me to export the HTML table to XLS using the "save as" option. However, I want to enhance this functionality so that clickin ...

Using Vanilla JavaScript to Disable a Specific Key Combination on a Web Page

On a completely random English-Wikipedia editing page, there exists a way to add content (for example, "test") and save it using the existing key combination of Alt+Shift+S. My goal is to specifically prevent this action without removing the save button b ...