user123 user123 - 11 months ago 44
CSS Question

HTML Email : put transparent background color on image and text on it

I would like to have a text which is on transparent background layer and that background layer is on image.

As I am making HTML Emailer , so can't use

property. Have to use

How can I do so?

<img src="" style="width: 600px; height: 300px;">

I want a transparent background color layer on the image and some text on the background color layer.

PS: I can't use
. have to stick to
tag and inline css only.

Thank You.

Answer Source

You can use two tables for that.

  <table class="main-background" width="600px" cellspacing="0" cellpadding="0" border="0" bgcolor="#222325" align="center" style="border-collapse: collapse;   mso-table-lspace: 0pt;mso-table-rspace: 0pt; background-repeat: no-repeat; background-size: cover;" background="">
<td height="300" valign="top" align="center" style="">                            
  <table width="600" cellspacing="0" cellpadding="0" border="0" align="center" class="container" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt; background:rgba(245,86,26,0.4);">
  <tbody>  <tr><td>Your Text</td></tr><tr><td>Your Text</td></tr><tr><td>Your Text</td></tr><tr><td>Your Text</td></tr></tbody></table>

Try using this code.