Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML's Table TD with default value

Tags:

html

Is there any way to fill the empty <td></td>, if data does not exist in this?

<table><tr><td></td><td>1</td><td></td></tr></table>

Change it to:

<table><tr><td>Not Data</td><td>1</td><td>No Data</td></tr></table>
like image 973
Anurag Choudhary Avatar asked Sep 23 '26 07:09

Anurag Choudhary


2 Answers

A little bit hackish, because it changes only visual aspect. You can do that with CSS:

table, td {border: 1px solid black; padding: 4px; border-collapse: collapse}
td:empty::before {content: "No Data"}
<table>
  <tr>
    <td></td>
    <td>Real data</td>
    <td></td>
  </tr>
</table>
like image 65
MaxusR Avatar answered Sep 25 '26 07:09

MaxusR


Not with HTML itself.

Usually you would do this by generating the HTML using a data in a programming language and a template, with template logic used to insert a default value if none came from the data.

like image 33
Quentin Avatar answered Sep 25 '26 07:09

Quentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!