Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you make a HTML table partially transparent?

If I have a HTML table like the one below:

<table bgcolor="#151515" height="100" width="200">
<tr>
<td>
Hello
</td>
</tr>
</table>

How can I make it partially transparent? Is there a way of doing it without CSS? If not what is the CSS way?

like image 478
James Avatar asked Dec 10 '22 06:12

James


1 Answers

You can try this in your html file:

<table class='table1'>
<tr><td>...

And this in your css file:

.table1 {
background: rgba(255,255,255,0.5);
}

This sets the rgba RED GREEN BLUE ALPHA values, 255,255,255 = white, 0,0,0 = black, and the 0.5 value at the end (ALPHA) is between 0 and 1, where 1 is opaque and 0 is transparent. I hope this helps.

In your case, #151515 (HEX CODE) translates to (21, 21, 21, 0.5) (RGBA) where A is equal to 50% transparent.

like image 133
Michael Avatar answered Feb 07 '23 21:02

Michael