+ 1

The Line Break In Table Data

In an example under the topic "Tables" in HTML, there's a <br /> tag within the <td> element. Why is it? Is it required? If it is, what does it actually do?

12th May 2017, 6:24 AM
Yuan Lin
Yuan Lin - avatar
1 Answer
+ 3
You just put a new line in the cell... but it's not required. However, what's required is to put some content inside a <td> element, if you want display borders of the cell: default befaviour of html tables is to not display empty cells. Anyway, usual old workaround is to put a non breakable white space ( &nbsp; ), but fill an empty cell with a <br> element will do the same. But it's tricky and need adaptation in some case, as technically, the cell is no longer really empty ^^. Today Css can do the job properly, by using 'empty-cells: show;' applied to the <table> element ;)
12th May 2017, 8:16 AM
visph - avatar