Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Table with No Space

I have the following CSS code:

    tr.uprightTr
    {
        padding: 0px;
        margin: 0px;
        height: 10px;
        border: none;
        border-spacing: 0px;
    }
    td.uprightTd
    {
        padding: 0px;
        margin: 0px;
        height: 10px;
        border: none;
        border-spacing: 0px;
    }
    table.uprightTbl
    {
        padding: 0px;
        margin: 0px;
        border: none;
        border-collapse: collapse;
        border-spacing: 0px;
    }

And the following HTML:

<table class="uprightTbl" cellpadding="0" cellspacing="0">
    <tr class="uprightTr">
         <td class="uprightTd"><input type="checkbox" /></td>
...

No matter what I tried, it keeps some space between elements. Any ideas on what I can try or might be doing wrong?

P.S: I also checked out the element on Chrome, element reaches the related css lines successfully.

like image 764
İsmet Alkan Avatar asked Dec 04 '12 18:12

İsmet Alkan


People also ask

How do I remove spaces from a table in HTML?

The space between the table cells is controlled by the CELLSPACING attribute in the TABLE tag. By setting CELLSPACING to zero, you can remove all the space between the cells of your table.

How do I remove spaces from a table in CSS?

To remove this space we can use the CSS border-collapsing Property. This Property is used to set the borders of the cell present inside the table and tells whether these cells will share a common border or not.

How do you make a blank table in HTML?

Complete HTML/CSS Course 2022 To create table in HTML, use the <table> tag. A table consist of rows and columns, which can be set using one or more <tr>, <th>, and <td> elements. A table row is defined by the <tr> tag. To set table header, use the <th> tag.


2 Answers

Did you try to add a CSS rule for all elements such as:

.uprightTbl * {
    border: none;
    border-collapse: collapse;
    padding: 0;
    margin: 0;
}

It may solve your problem.

like image 97
Ulflander Avatar answered Oct 11 '22 16:10

Ulflander


Apply below styles:

border-spacing:0;
border-collapse:collapse;

This query is already present: Set cellpadding and cellspacing in CSS?

like image 20
Rups Avatar answered Oct 11 '22 15:10

Rups