Search code examples
htmlpngtransparency

Cannot add .png with transparent background or any picture to an HTML page


I created an HTML page like that:

<!DOCTYPE html>
<html>
    <head>
        <title>Title</title>
        <style>
            body {
                background-color: bisque;
            }
        </style>
    </head>
    <body>
        <img src="/cat.png">
    </body>
</html>

And cat.png picture looks like this:

enter image description here

It has a transparent background. But my page looks like that:

enter image description here

So, the question is: Why isn't the picture displaying on the page?


Solution

  • Turns out I needed to add a dot to the path to the picture like that:

    <img src="./cat.png">