title: How to overlay an image/watermark with pure CSS and HTML
body: <p>Is there an easy way with relative positioning to overlay a transparent PNG (or any other image) over an image tag with CSS just by passing a class?</p>
  
  <pre><code> &lt;img class="watermarked" src="http://placehold.it/500x325.jpg" alt="Photo"&gt;
  </code></pre>
  
  <p>Then the CSS might be similar to this (not working):</p>
  
  <pre><code>.watermarked{
    background-image: url("http://placehold.it/100x100/09f/fff.png");
    position: relative;
    left: 30px;
    opacity: 0.5;
  }
  </code></pre>
  
  <p>Ideally, I would be able to define the path of my "watermark" overlay image within CSS and then any image that I add "watermarked" class to would get this image overlaid on top with some negative relative positioning.  It should be able to be applied to multiple images on a single page, so a single use DIV will not work.</p>
  
  <p>Obviously, this does NOT do anything to protect the underlying image...so to call it a watermark is not really accurate...more of a temporary overlay. I am amazed that an answer is not readily available but I have poked around and not found an answer here or on google.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.watermarked {
    background-image: url("http://via.placeholder.com/100x100/09f/fff.png");
    position: relative;
    left: 30px;
    opacity: 0.5;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="col-lg-3 col-md-6 mb-4"&gt;
    &lt;div class="card"&gt;
      &lt;img class="card-img-top watermarked" src="http://placehold.it/500x325" alt=""&gt;
      &lt;div class="card-body"&gt;
        &lt;h4 class="card-title"&gt;Card title&lt;/h4&gt;
        &lt;p class="card-text"&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sapiente esse necessitatibus neque.&lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
    </p>