Background Image on a HTML element


« Previous Next »

To add a background image on an HTML element, use the HTML style attribute and the CSS background-image property:

Example

Add a background image on a HTML element:

<p style="background-image: url('cat.jpg');">

You can also specify the background image in the <style> element, in the <head> section:




Output




Live Demo & Try it yourself!