Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reducing HTML Table Row Height

Tags:

html

css

I have table with few rows. I want 1st and 3rd row height to be set to 1 px and the 2nd row to normal height. But my code is not working.

enter image description hereHTML CODE goes below

<table border="0">
   <tr style="height:2px;" >
    <td width="10"><hr></td>

  </tr>
<tr style="height:20px;" >
    <td width="10">Hello</td>

  </tr>
  <tr style="height:20px;" >
    <td width="10"><hr></td>

  </tr>
</table>

Could anyone please tell me how to do it ?

Note: I dont want borders to be used because i Want for certain rows i may or may not need the horizontal line inside the rows.

like image 291
logan Avatar asked Nov 27 '13 19:11

logan


People also ask

How do I reduce row height in HTML?

The height of rows 'tr' in a table can be fixed very easily. This can be done by adding the height attribute in the tr tag. If the height is not specified, the height of the row changes according to the content. The height can be specified either in pixels, or percentage.

How do you decrease the height of a table row?

Change row height To set the row height to a specific measurement, click a cell in the row that you want to resize. On the Layout tab, in the Cell Size group, click in the Table Row Height box, and then specify the height you want. To use the ruler, select a cell in the table, and then drag the markers on the ruler.

How do you change the height of a table cell in HTML?

To set the cell width and height, use the CSS style. The height and width attribute of the <td> cell isn't supported in HTML5. Use the CSS property width and height to set the width and height of the cell respectively.

How do I reduce the size of a table in HTML?

To manipulate the height or width of an entire table, place the size attribute (either "WIDTH=" or "HEIGHT=") within the <TABLE> code. To manipulate individual cells, place the size attribute within the code for that cell.


1 Answers

Add style="padding:0px; margin:0px;" to your hr and change the height of your third tr to 2px

You will have :

<table border="0">
   <tr style="height:2px;" >
    <td width="10px"><hr style="padding:0px; margin:0px;"></td>
  </tr>
<tr style="height:20px;" >
    <td width="10px">Hello</td>
  </tr>
  <tr style="height:2px;" >
    <td width="10px"><hr style="padding:0px; margin:0px;"></td>
  </tr>
</table>
like image 108
Marc-André Bilodeau-Lamontagne Avatar answered Oct 10 '22 23:10

Marc-André Bilodeau-Lamontagne