Removing white lines within a html table with CSS is achievable by utilizing the border-collapse property and setting it

My goal is to design a profile box that displays the user's profile picture along with account-specific information and utilities such as username, settings button, profile page link, etc. To achieve this, I utilized a table element centered using flex properties. Additionally, I applied background colors to div elements for clarity. However, I encountered white lines between cells in my table, which I tried to resolve by using the border-collapse attribute. Although some of the lines disappeared, there were still remnants visible. Interestingly, these lines seemed to disappear when zooming in and out using ctrl + scroll, suggesting a potential rounding error.

What should be my course of action?

.Leftside2 {
  flex: 20%;
  background-color: red;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
}

.profile {
  width: 90%;
  border: 2px solid black;
  display: flex;
  justify-content: center;
  border-collapse: collapse;
}

#profile_picture {
  height: 100%;
  padding: 5px;
  background-color: orange;
  display: flex;
  justify-content: center;
}

#profile_picture img {
  width: 80%;
  height: 80%;
}

.friend_list {
  width: 90%;
}
<div class="Leftside2">
  <table class="profile">
    <tr>
      <td style="height: 30vh;border-width: 0px">
        <div id="profile_picture"><img src="https://via.placeholder.com/450x400"></div>
      </td>
    </tr>
    <tr>
      <td style="border: 0 solid black; background-color: orange">Jill</td>
    </tr>
    <tr>
      <td style="border-width: 0px">Eve</td>
    </tr>
    <tr>
      <td style="border-width: 0px">John</td>
    </tr>
  </table>
  <table class="friend_list">
    <tr>
      <td>Friends List</td>
    </tr>
    <tr>
      <td>content</td>
    </tr>
  </table>
</div>

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

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

Edit: Despite attempting cellpadding="0" and cellspacing="0" within my table tag, the issue persisted. Explicitly setting margin=0 and padding=0 for all table elements did not resolve it either. It appears to be more complex than just a margin or padding problem as suggested by others.

Edited code:

.profile {
    width: 90%;
    border: 2px solid black;
    display: flex;
    justify-content: center;
    border-collapse: collapse;
    padding: 0;
    margin: 0;
}

.profile td {
    padding: 0;
    margin: 0;
}

Second edit:

<html lang = "en">
<head>
    
        <link rel="stylesheet" href="../css/style.css">
        <title>Find a Friend</title>
    
</head>
<body>
    <div class="HeaderMenu">
        <div style="margin-left:40px;margin-right:100px;background-color: #008aed;">    
            <a href="logout.php" target="_self" class="logout_button_link"><button class="logout_button">Logout</button></a>
        </div>
    </div>
    <div class="row">
        <div class = "left_space"></div>
        <div class="Leftside2">
            <table class="profile" cellpadding="0" cellspacing="0">
                <tr>
                   <td style="height: 30vh;border-width: 0px">
                        <div id="profile_picture"><img src="../img/placeholder.png"></div>
                    </td>
                </tr>
                <tr>
                    <td style="border: 0 solid black; background-color: orange">Jill</td>
                </tr>
                <tr>
                    <td style="border-width: 0px">Eve</td>
                </tr>
                <tr>
                    <td style="border-width: 0px">John</td>
                </tr>
            </table>
            <table class="friend_list">
                <tr>
                    <td>Friends List</td>
                </tr>
                <tr>
                    <td>content</td>
                </tr>
            </table>
        </div>
        <div class="Centerside2">
            
        </div>
        <div class="Rightside2">
            
        </div>
        <div class = "right_space"></div>
    </div>
</body>

Answer №1

  .user-info td {
      margin: 0;
  }

To fix the issue, include the above code in your CSS file or alternatively, you can include cellpadding="0" within the table tag in your HTML.

Answer №2

Consider including the following code within your table element:

cellspacing="0"

Padding pertains to the interior space of the cell, while cell spacing determines the amount of space around it.

Answer №3

To resolve the problem, simply include the attribute cellpadding="0" within your table element.

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

Content within div elements in Hypertext Markup Language

I am in the process of creating a website to showcase my skills as a pianist. I am sticking to using only HTML and CSS for now, as I have yet to explore JavaScript or Flash. It's all still very new to me since I just started learning HTML two days ago ...

Organizing an HTML layout

Looking for a way to sort a div structure based on a parameter, I came across a small JavaScript that seems to not work as expected. It appears that the sorting function is not parsing the values perfectly... This is the logic I am using for sorting: < ...

Having trouble finding rows to manipulate in an HTML table generated using jQuery csvToTable?

As a beginner in programming, I find myself seeking assistance with a particular issue. I have successfully read a CSV file stored locally and transformed it into an HTML table using jQuery csvToTable http://code.google.com/p/jquerycsvtotable/. Additional ...

Are there any tools available for selecting fonts to use in an input form for users?

I am currently seeking a font picker tool that can be integrated into my web project to allow users to select from a variety of fonts. I have implemented a basic code using radio buttons, which seems to be functioning as intended: <label style="font-fa ...

Error message: "AngularJS encountered a $injector:modulerr error in Internet Explorer 11."

I've successfully created an AngularJS App that functions properly on most browsers like Firefox, Opera, Safari, Edge, and Chrome. However, there seems to be a compatibility issue with IE 11. When attempting to open the app in IE 11, the following er ...

Learn a valuable trick to activate CSS animation using a button - simply click on the button and watch the animation start over each time

I already know how to do this once. However, I would like the animation to restart or begin again when the user clicks on it a second time. Here is what I have: function animation() { document.getElementById('ExampleButton').className = &apo ...

What is the process of transitioning to keyup?

I am looking to replace the ready event with a keyup event. Here is my code snippet: $(document).ready(function(){ $('#coke').validate({ rules : { coek : { required: true, minlength: 6, maxlength: 6 ...

How can I use JavaScript to consistently fetch the CSS-defined percentage setting for padding/margin instead of the pixel size?

How can I retrieve the padding set in CSS for a div with {padding:10% 10px 20% 10px;} using JavaScript, considering that window.getComputedStyle(myelement).getPropertyValue('padding'); returns different results? In Firefox, it shows as "10% 10px ...

Exporting jsPDF without maintaining the original CSS styling

I've got this code that I'm using to export HTML to PDF, and it's functional; however, the CSS is not being applied. <body> <div class="container"> <div style="background-color: yellow" id="pagina">Page to ...

Incorporating a linear-gradient to tint a background image proves to be ineffective

I'm attempting to apply a transparent linear gradient to tint an image. However, the developer tools are detecting my property as invalid. Interestingly, when I remove the gradient, the image displays correctly. Could there be something crucial I am o ...

The PHP code doesn't display the slider, whereas it appears on the HTML page

Creating a shortcode for a slider that displays WordPress featured posts and allows users to view details of each post through a hidden div. The slider is inspired by the one on w3schools, where you can find the code and test it online at this link: https: ...

Detecting Android devices

Issue: My website functions properly on desktop but has a problem with the carousel images skewing on iPhones. To address this, I created a separate CSS styling for iPhone devices and used a JavaScript function found online to detect iPhones and iPads. Un ...

Stuck autoplay feature when clicking

There is an issue with the play function in the built-in browser audio player. Initially, it starts automatically with the following code... function play(){ var audio = document.getElementById("myaudio"); audio.play(); } However, when modifying the code ...

A guide on incorporating an event to multiple elements in vue.js

I am trying to implement a double-click event on multiple elements in Vue3. My goal is to create a table of contents data and add a double-click event to the checkboxes and favorite icons without using @dblclick="". I find it more convenient to assign a c ...

Looking for assistance in personalizing a Tab slider plugin with jQuery and CSS?

Hi there! I stumbled upon this post (http://stackoverflow.com/questions/7645702/tab-slide-out-using-jquery-need-more-than-one) while experimenting with a plugin. I'm curious if anyone here knows how to integrate this plugin into a menu. My idea is to ...

A code snippet designed to ensure uniform height for all floating div elements

Hello, I am facing an issue with resizing 20 left-floated divs of varying heights on my website. Previously, when my website was designed using pixels, a script worked perfectly for resizing them. However, after switching to a percentage-based design (% d ...

bootstrap 4 - logo in navbar brand stays the same even when scrolling

I integrated Bootstrap 4 and successfully created a navbar. However, I am encountering a conflict when trying to change the navbar logo upon scrolling down. Despite my efforts, it is not functioning as expected. Does anyone know how to resolve this issue? ...

Eliminate the div element using jQuery if it contains a line break tag but no text

I am faced with a situation on a page where some div elements contain content while others only have a BR tag. I am attempting to remove the div elements that contain only the BR tag. Below is the HTML format in question: Here is an example of one type: ...

Building a Dynamic CSS Grid

Today is the first time I'm reaching out for help rather than figuring things out on my own. I'm currently working on a website layout that consists of visible tiles all with equal sizes, forming a grid structure. The challenge I face is making t ...

Could you please guide me on resolving the Blazor/Bootstrap 5 CSS problem related to styling "striped" tables?

Looking for a solution to fix a CSS issue involving Bootstrap 5 "table-striped" and displaying Blazor Razor components. In my Blazor/Bootstrap 5 page, I have a table displaying content fetched from a service at runtime. Initially, the Bootstrap CSS is vis ...