What makes these two ul li a lists unique?

I am facing an issue with two inline unordered lists with list items as links. One list behaves as expected, while the other has a space between the link items.

ul {
  list-style: none;
  margin: 0;
  padding: 0
}
li {
  display: inline;
}
a {
  border: 1px solid black;
  font-size: 1rem;
}
<br>
<nav>
  <ul>
    <li><a href="#">ONE</a>
    </li>
    <li><a href="#">TWO</a>
    </li>
    <li><a href="#">THREE</a>
    </li>
  </ul>
</nav>
<br>
<nav>
  <ul>
    <li>
      <a href="#">
              ONE
            </a>
    </li>
    <li>
      <a href="#">
              TWO
            </a>
    </li>
    <li>
      <a href="#">
              THREE
            </a>
    </li>
  </ul>
</nav>

One navigation set displays without any space between the items, while the other shows spaces in between each link item. Refer to the image for a visual representation of the issue:

https://i.sstatic.net/uK4oX.png

Answer №1

If there is excessive whitespace in the HTML, the browser will treat it as a single space. To fix this issue, delete the extra spaces in the area where you see ONE TWO THREE.

Answer №2

The first scenario involves whitespaces placed outside of the anchor tags, while the second scenario has spaces placed inside the tags. This results in the link text containing whitespace.

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

What is the best way to extract text from a string that is enclosed by two particular words?

Using Ajax, I am extracting the complete HTML code from JSON. Once fetched, the string appears as follows : <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="Content-Type" cont ...

Learn how to retrieve the current input value from a repeating form using Jquery

I have implemented a comment system with a delete option. Each comment has a POST form that posts a comment-id to delete.php. While this works in PHP, I am facing issues with it in jQuery. To delete a comment, the comment id needs to be passed to delete.p ...

The form contains an HTML table, but unfortunately, the buttons are not functioning as expected

I have encountered an issue with my form and table setup that I cannot seem to resolve. Despite researching similar problems, I have not been able to find a solution. In the code snippet provided below, you can see that when I click on the buttons for De ...

Commence the element on a fresh line

I am looking to format the code below so that the .filter-containers are displayed next to each other in rows. If a .filter-container has a .header-container, it should start on a new line and the remaining .filter-containers will continue to sit next to i ...

Using CSS properties as false values within React applications

Can you provide guidance on using conditional styles with conditional operators? What would be the ideal code example? Is it possible to use non-CSS values? margin: isOpen ? '10px' : undefined margin: isOpen ? '10px' : 'initial&a ...

Changing the background color and text color on hover using CSS

Is there a way for the menu to change both the background and text color when I hover over it? Currently, my CSS only changes the background color but not the text color. Any help would be appreciated. a:hover { color: #231f20; //for new text co ...

Attempting to serialize a form using Ajax and jQuery

I am facing an issue with submitting user input from a modal using jQuery and AJAX. The problem is that the AJAX call is not capturing the user input. Even though the AJAX call is successful, when I check on the server side, the user input appears to be bl ...

What could be causing my DIV anchor link to appear larger than the image it is supposed to be

Recently, I have rearranged my delete and like buttons within a DIV tag. Interestingly, even though I have meticulously set the width and height of the div tags to match that of the image, they still appear below the "Like" button. Additionally, I've ...

Box size adjusts to fit its content, including any form fields

Looking to create a box that adjusts its size based on content and center it without resorting to using tables for layout or setting fixed sizes. How can this be achieved while keeping the markup clean? I've almost got it, but the form fields are not ...

How can I validate HTML input elements within a DIV (a visible wizard step) situated within a FORM?

I recently made a decision to develop a wizard form using HTML 5 (specifically ASP.NET MVC). Below is the structure of my HTML form: @using (Html.BeginForm()) { <div class="wizard-step"> <input type="text" name="firstname" placeholder ...

JavaScript Date Validation: Ensuring Proper Dates

I am working with a date string that is in the format of "DD-MM-YYYY" and have successfully validated it using this code: var dateFormat = /(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[012])-\d{4}/ ; if(!startDate.match(dateFormat)){ alert("'Start Dat ...

Table-driven forms in Angular

I am facing a requirement where I need to submit a form containing five records in a table format. Here is how the table looks: https://i.sstatic.net/82ZFM.png This is the code snippet for the form: <form [formGroup]="FeedBack" (ngSubmit)=&q ...

Is there a way to prevent webpages from automatically refreshing parts of their content?

I'm trying to figure out how to prevent the webpage from automatically refreshing itself. I use Safari or Chrome to browse wsj.com or Yahoo Finance, and I've noticed that the page can refresh on its own or some numbers keep changing (like the ind ...

Implement a fullscreen hero image on a specific blogroll template page in Wordpress

My portfolio website uses custom page templates for each page. The blog page is not the landing page, but an interior page. I have been able to add a custom hero image to every page template except for the blog page. Currently, I am using the content.php p ...

Manipulate the default option in a Select field with JavaScript

I'm currently working on a WordPress post editing page and I need to set up a target link: By default, the option is set to "None", but I want to change it to "Custom Link..." with the following details: <select name="imt_team_href" onchange="imt ...

Tips for disabling Bootstrap dropdown's preventDefault function- Ways to remove preventDefault

I have incorporated the Bootstrap 3 dropdown menu into my code, but I want it to pop out when I hover over the elements instead of the default behavior. To achieve this, I wrote a small script: jQ('.dropdown').hover(function() { jQ(this).fin ...

Undesirable gap found within the bootstrap columns

I'm experiencing issues with the design of my form controls in Bootstrap. I have divided the screen into three columns, with each column being 4 md wide. The General Agreement control is defined as col-md-8 to span across. I'm unsure why there is ...

Encountering a problem with my Solidity map(int,string) function when attempting to use JavaScript to pass values back to HTML

I'm struggling to update my labels using a JavaScript function call to my Solidity smart contract. My goal is to create a map with integer and string values in Solidity, then display these values in HTML upon clicking a button. But for some reason, th ...

The navigation bar spills over the page content

I recently built a website using Bootstrap 3, but I'm facing an issue in responsive mode with the horizontal scroll bar on my index.html page. Strangely, this overflow-x problem is isolated to just this particular page and doesn't occur on any of ...

Ways to remove the address bar from a mobile browser like Chrome or an Android browser

Is there a way to make videojs go full screen on Android devices when the URL is entered, without displaying the address bar? ...