Troubleshooting problems with Chrome rendering a table row border CSS that is only 1 pixel wide

While there are numerous discussions online about Chrome's rendering issues with table borders in CSS, I have come across a frustrating inconsistency specifically with the border applied to the <tr> element. In the example below where I set border-bottom: 1px solid #000 on the <tr>, Chrome displays thicker borders on the first, third, and fifth rows. Surprisingly, changing the border width to 0.5px or 2px results in consistent rendering across all rows. This issue does not seem to affect Firefox. Could this be a bug unique to Chrome? Are there any workarounds besides adjusting the border width from 1 pixel? You can also view the problem in action on CodePen here.

*Edit: It is worth mentioning that I am using Windows 11 on a 4k monitor with scaling enabled in display settings, which raises the possibility of an OS-related cause.

table {
      border-collapse: collapse;
      width: 100%;
    }
    thead {
      border-bottom: 2px solid #000;
    }
    thead th {
      font-weight: bold;
      padding: 15px 0;
    }
    tbody td {
      padding: 20px 0;
    }
    tbody tr {
      border-bottom: 1px solid #000;
    }
<table>
      <thead>
        <th>Heading 1</th>
        <th>Heading 2</th>
        <th>Heading 3</th>
        <th>Heading 4</th>
      </thead>
      <tbody>
        <tr>
          <td>Data 1</td>
          <td>Data 2</td>
          <td>Data 3</td>
          <td>Data 4</td>
        </tr>
        <tr>
          <td>Data 1</td>
          <td>Data 2</td>
          <td>Data 3</td>
          <td>Data 4</td>
        </tr>
        <tr>
          <td>Data 1</td>
          <td>Data 2</td>
          <td>Data 3</td>
          <td>Data 4</td>
        </tr>
        <tr>
          <td>Data 1</td>
          <td>Data 2</td>
          <td>Data 3</td>
          <td>Data 4</td>
        </tr>
        <tr>
          <td>Data 1</td>
          <td>Data 2</td>
          <td>Data 3</td>
          <td>Data 4</td>
        </tr>
      </tbody>
    </table>

Answer №1

To fix the issue with the odd 2px lines, I made adjustments by eliminating padding and using height settings instead. Hopefully, this solution works for you!

table {
    border-collapse: collapse;
    width: 100%;
    border-spacing: 0;
    thead { 
        border-bottom: 0.9px solid #000;
        th {
            font-weight: bold;
            /*padding: 20px 0;*/
            height: 20px;
        }
    }
    tbody {
        td {
            /*padding: 20px 0;*/
            height: 40px;
        }
        tr { 
            height: 20px;
            border-bottom: 0.9px solid #000;
        }
    }
}

View the updated design here

Answer №2

This issue has crossed my path numerous times, and I have successfully addressed it without altering the border width. Take a look at the code snippet below for the solution:

table {
  border-collapse: collapse;
  width: 100%;
}
thead {
  border-bottom: 2px solid #000;
  display: block;
}
thead tr {
  display: block;
}
thead th {
  font-weight: bold;
  padding: 15px 0;
  display: inline-block;
  width: 24%;
  text-align: left;
}
tbody td {
  padding: 20px 0;
  display: inline-block;
  width: 24%;
}
tbody tr {
  border-bottom: 1px solid #000;
  display: block;
}

The CSS code above illustrates how I included the display:block; property in place of the border property. Without the display property, the table border doesn't function correctly. Additionally, I have incorporated other CSS adjustments to enhance the UI appearance.

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

Adding and removing dynamic fields with Bootstrap functionality

Recently, I've been trying to develop a feature where users can add and remove fields by clicking on a button. However, I've encountered a roadblock in my progress. If you take a look at this CodePen link, you'll see what I have so far. My a ...

A guide on aligning a DIV to the left of another DIV with Bootstrap

In order to achieve a checkerboard style layout for a webpage using HTML, I am looking for a solution where the image is positioned to the left in the first row and to the right in the second row. I want to explore if this can be accomplished purely with C ...

Common pitfalls and glitches when working on WebKit for iOS and Android development

Embarking on the development of a significant touch-enabled mobile WebKit application. In search of any suggestions or recommendations regarding differences from standard desktop-based browsers. For instance: In iOS, click events do not bubble up to ...

Creative ways to design the HTML5 `<meter>` tag

I am curious about how to style the <meter> tag in a new way. <meter value=80 min=0 max=100> 80/100 </meter> All I want to do is customize the background color and the value color, but I haven't been able to locate the appropriat ...

Attributes required are not functional on mobile devices

Good day! I have encountered an issue with the required attribute on a form on my website. It seems to be working perfectly on my browser, but not on mobile devices. Has anyone else experienced difficulties with jQuery, JavaScript, or Node packages? <f ...

Move the div with jQuery

I am currently working on making a div draggable without relying on jQuery UI. Here is the HTML code: <div class="wrapper"> <div class="toddler"></div> </div> And here is the script I have written: $.fn.slider = function () { ...

JQuery method for extracting a specific span's content from a div

I am faced with extracting specific text from a span within a div element. Below is the code snippet for my Div: '<div class="dvDynamic_' + pid + '"><p hidden="true">'+pid+'</p><span class="count_' + pid ...

Merge diverse backgrounds with Parallax Scrolling

My Parallax scrolling website has a div called "bg" with dimensions of 8000px height and 960px width. The entire page is designed to fit this size, including the body background. However, I am facing an issue where setting the background for "bg" breaks th ...

Docker is throwing a NoSuchElementExeption, but everything runs smoothly on localhost

I have developed an automated test using Selenium, and it runs successfully in Eclipse. However, when I try to run it in Docker, I always encounter the NoSuchElement Exception. I am hoping that someone can assist me with this issue. Here is a snippet of my ...

Determine the body's height by adding the heights of the header and footer

In my design, there is a header with a height of 8rem; .header { top: 0; left: 0; height: 8rem; } Following that, there is a footer with a height of 5rem; footer { width:100%; height: 5rem; } I am attempting to calculate the heig ...

Detecting Triple Taps on Mobile Devices

I've been trying to incorporate a triple-tap escape feature similar to The Trevor Project's Website. It functions flawlessly on laptops and desktops with a mouse. However, I'm struggling to detect the triple tap on mobile browsers because th ...

At the top of this list is the incomplete line, eager to be

I created a unique flexbox design showcasing various elements. These elements behave like text, flowing inline and wrapping as needed, but expanding equally to fill the available space on the line. However, I encountered a challenge: My goal is for it to ...

Having difficulty populating a form with multiple array values using a loop

I could use some assistance with this issue. I am attempting to populate a form using values from an array, but it's causing problems with the form. My goal is to show the af_rating in the input fields <?php $af_skill = array(12, 9, 6, 3, 4, ...

Body section CSS selector

Can a CSS selector be included within the body section of an HTML document? Here's an example of my code (although it is not functioning as expected): <html> <head> </head> <body> <div style= "a[target=_blank] {backgroun ...

How to retrieve an anchor element from a list using JavaScript

My current code loops through each <li> within a <td> cell and adds a class to the <li>. I have now inserted <a> tags between each <li> and am facing challenges in accessing the <a> tags. What I actually want is to assig ...

Interactive menu backdrop determined by div element

I am working on a website with a menu structured like the following: Home -- Work -- Pricing -- Contact Us -- About This website uses a one-page layout and has enabled Scrollspy on Bootstrap. I need to make the active menu background dynamic depending o ...

What is the best way to move to a new line without creating a space between the current line and the new line?

I am trying to achieve the desired output: $text = Hello, this is example text. rather than: $text = Hello, this is example text. When I use \n, it starts a new line. How can I make it stay on the same line below with the same startin ...

When I click the button, the loading.gif fails to appear

I'm having trouble getting my loading screen to display when my button is clicked. The Ajax function works fine, but the loading screen is not showing up. CSS <style> #display_loading{ position: absolute; top: 50%; left: 50%; transform ...

Is there a way to accurately determine the width of a DOM element in a ReactJS application?

While working on a web application using reactjs, I encountered an issue with creating a video player within a specific div container. To address this, I implemented the functionality in the 'componentDidMount' function as shown below: componen ...

Toggle the visibility of select options based on another select option

Hello everyone, I need some assistance. I am attempting to display a set of select options based on the selection made in another select option. There is a select option named "children" with a group of other select options that should be hidden by default ...