Delete any extra spaces in the table if it is the initial child of a list item

Is there a way to eliminate the empty space in the second list item?

I attempted

li > table:first-child { display: inline-table }

However, the xyz text shifts to the right of the table instead of staying below it.

Furthermore, I am unable to modify the HTML structure.

<ul>
 <li>list item one</li>
 <li>
  <table>
   <tr>
    <td>list</td>
    <td>item</td>
    <td>two</td>
   </tr>
   <tr>
    <td>aaa</td>
    <td>aaa</td>
    <td>aaa</td>
   </tr>
   <tr>
    <td>bbb</td>
    <td>bbb</td>
    <td>bbb</td>
   </tr>
  </table>
  xyz
 <li>list item trree</li>
</ul>

Answer №1

You're facing a challenge with the interplay of border-spacing within the table and padding applied to the td elements.

The distance between words in list item one is determined by a single space character's width - achieving this alignment for subsequent lines involves a complex combination of border-spacing and cell padding.

To address this issue, it may be beneficial to set the table and table rows as block elements, and the table cells as inline-block elements.

table, tr { display: block; border-spacing: 0; }
td { display: inline-block; padding: 0; }
<ul>
 <li>list item one</li>
 <li>
  <table>
   <tr>
    <td>list</td>
    <td>item</td>
    <td>two</td>
   </tr>
   <tr>
    <td>aaa</td>
    <td>aaa</td>
    <td>aaa</td>
   </tr>
   <tr>
    <td>bbb</td>
    <td>bbb</td>
    <td>bbb</td>
   </tr>
  </table>
  xyz
 <li>list item trree</li>
</ul>

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

Incorporate an external website's header and footer onto my own website

In the process of developing a new website, subdomain.example.com, it is important to note that it will operate in a separate environment from example.com. Despite this difference, both sites will feature the same layout in order to maintain a consistent u ...

What is hindering me from fetching the information stored in my json file?

Currently, I am delving into learning AngularJS by working on a simple webpage for a company. This page will showcase products that are fetched from a json file. Following a tutorial from the AngularJS website, which covers the exact task I aim to achieve, ...

Arranging extensive menu sections and content containment

I am currently working on enhancing my website's navigation by creating a mega menu. However, I am facing issues with the organization of the divs containing the ul content. In the fiddle linked below, you can see that "Africa", "Asia", and "Oceania" ...

What are some effective strategies for avoiding empty fields showing on an email form?

My HTML form is linked to a PHP Email handler, and it's working well except for one issue. When the email is delivered, it includes all fields, even the empty ones. I want it to only display filled-in fields. I tried using an IF statement that checks ...

Unusual conduct exhibited by jQuery's css() function for setting the width

My goal is to retrieve the width of the initial .imagen element and apply it to the img within .imagen. HTML: <div class="imagen"> <div class="normal"> <img> </div> <div class="hover"> <img> ...

Issue with tile size or alignment in Safari

Recently, while creating my portfolio on CodePen, everything was running smoothly except for one little hiccup - Safari. http://codepen.io/tpalmer75/pen/FijEh (SASS for just one .item element) .item width: calc(100% / 3) display: inline-block height ...

Using SVG Mask to enhance shape Fill

I am having trouble achieving the desired effect of darkening the fill of objects based on a specified gradient. Instead, when the mask is applied over the fill, it actually lightens it. I suspect that this issue arises from the color blending method being ...

Email design tip: Ensure consistent line heights by adjusting code for Outlook.com to override any default settings. Use the following CSS code: ``

I've been trying to fix this problem for 22 hours now, but as a newcomer, I think it's time to hand it over to the pros. I've been attempting to get rid of the extra line height that Outlook.com adds to emails, but I haven't had any lu ...

Having trouble choosing an item from the Select2 drop-down menu

I have been developing an application that incorporates Select2 (version 3.5.1). The HTML used to create the dropdown / autocomplete field is as follows: <input id="mySelect" class="form-control" type="hidden"> The snippet above includes the form-c ...

What is the best way to align HTML elements in a single row?

I have the following code snippet... <div class="header"> <div class="mainh"> <div class="table"> <ul> <li><a>smth</a></li> ...

I am looking to incorporate one word in my heading to be displayed horizontally, with the second word flowing vertically

I am designing a website and looking to create a unique effect with the text in my title/h1 tag. I want the first word to be displayed horizontally and the second word vertically. My attempt using span tags in the h1 element only allowed me to change the ...

My PHP script encountering issues retrieving POST values

I am encountering an issue with my HTML login form and PHP processing. The form is supposed to POST values to /user.php, where my authentication class handles the login process. However, I am having trouble getting the form to actually submit the data. He ...

Javascript involved in the process of CSS Background-Images loading after HTML Images

I quickly put together a microsite that is located at . If your internet connection isn't fast or nothing is cached, you may notice that the background-images used for CSS image-text replacement are the last items to load (especially the h1#head with ...

Placing the navigation bar on the right side of the section

.middle-site-content-container { width: auto; height: auto; border: 2px red solid; display: flex; /*Le pot pozitiona in line*/ flex-wrap: wrap; justify-content: center; flex-direction: row; margin: auto; } .middle-site-content-1, .middle ...

The CSS performs perfectly in IE9 but displays completely disorganized in IE8

I am facing issues with my CSS styles in IE8, specifically with border radius and background gradients, as well as the size of the container. I have tried using CSS PIE to fix it, but that also didn't work. If anyone has any suggestions or solutions, ...

Customize the select option in HTML to hide the default arrow and provide additional spacing for the options

I am dealing with a select option markup that looks like this <div class="styleselect"> <select onchange="setLocation(this.value)" class="selections"> <option selected="selected" value="position">Position</option> <opt ...

Is there a way to automatically increase a value by clicking on it?

Check out this code snippet I'm working with: let funds = document.createElement('funds') funds.style.color = 'green' funds.style.textAlign = 'center' funds.style.fontSize = '50px' funds.style.backgroundCol ...

Creating a JSON file using an object to send requests in Angular

In my Angular 7 project, I am trying to send a multipart request to the server that includes a file (document_example.pdf) and a json file containing a data object (data_object_example.json). The content of data_object_example.json is as follows: { " ...

Switch out the content within a div upon selection

I'm currently working on a palette board project and facing some challenges when switching to a different theme. The initial page is set to have a Warm color palette, but I intend to alter this once the user clicks on the All theme option. Users wil ...

Create a notification menu in Bootstrap using Bootply, which conveniently displays a numerical badge at the top

I am interested in implementing a bootstrap notification menu similar to the one found at this link: http://www.bootply.com/oasBuRC8Kz# However, I would like to add the number of notifications to the upper right corner of the glyphicon. I have gone throug ...