charlie
charlie

Reputation: 481

css background image not displaying in html table

i have added this style to a table

background-image:url(square_image.png); background-size:auto; background-repeat:no-repeat;

However the image is not being displayed in the background.

The demo Jsfiddle link here

Upvotes: 1

Views: 1760

Answers (2)

user2628521
user2628521

Reputation:

It is not allowed to use multiple attributes in HTML. Validate your HTML before asking on StackOverflow. https://validator.w3.org/

https://jsfiddle.net/ou366bh7/

style=""

Upvotes: 0

Nabeel Khan
Nabeel Khan

Reputation: 3993

This is because you're having two inline "style" attributes.

Your updated code should be like:

<table border="0" cellspacing="0" cellpadding="5" style="width:100%; min-width:500px; max-width:700px; font-family:Arial; font-size:14px;">
<tr>
  <td><table width="240" height="300px" border="0" cellpadding="2" cellspacing="0" style="font-size:12px; font-family:Arial;background-image:url('https://s32.postimg.org/wi1c9sm3p/Integra_Icons_Square_on_orange.jpg'); background-size:auto; background-repeat:no-repeat;">
                  <tr>
                    <td align="right">Text</td>
                    <td align="right">Text</td>
                  </tr>
                  <tr>
                    <td align="right">Text</td>
                    <td align="right">Text</td>
                  </tr>
                  <tr>
                    <td align="right">Text</td>
                    <td align="right">Text</td>
                  </tr>
                  <tr>
                    <td align="right">Text</td>
                    <td align="right">Text</td>
                  </tr>
                  <tr>
                    <td align="right">Text</td>
                    <td align="right">Text</td>
                  </tr>
              </table></td>
</tr>
</table>

Updated jsfiddle: https://jsfiddle.net/j03mp8bc/8/

Upvotes: 1

Related Questions