Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: How to make table cell border grow inwards

In a Javascript program (No CSS allowed, all styling is done in Javascript).

I wrote a program that increases the border thickness of a cell in a table when clicked (selected). I did this by setting the original border thickness to "thin" and then when clicked, changing the border thickness to "thick".

But when the cell is "selected", the width and height of the cell expands, which make it look like the table is shifting each time a cell selection is made.

Is there a way to prevent this?

like image 205
termlim Avatar asked Feb 06 '18 08:02

termlim


People also ask

How do you put a border around a cell in HTML?

The HTML <table> border Attribute is used to specify the border of a table. It sets the border around the table cells. Attribute Values: 1: It sets the border around the table cells.

How do you draw a border radius to a table?

Use the CSS border-radius property to add rounded corners to the table cells.

How do you make a thick border around a table in HTML?

You can get a quick border around your table by using the HTML border attribute. You determine the width of the border using a number. For example, for a thin border, use the number "1". For a thicker border, use a greater number.


1 Answers

You said no css? But can you use JavaScript to set a css style dynamically? In that case,

element.style.boxSizing="border-box"

That will allow the border to be part of the layout calculations. But if you really mean no dynamically setting styles, then I am not sure what you mean by all styling is done in JavaScript.

like image 50
jojois74 Avatar answered Oct 14 '22 00:10

jojois74