How to position text to top left position on an image with CSS

CSSWeb DevelopmentFront End Technology

To position text to top left, use the left and top property. You can try to run the following code to position text to left position on an image −


Live Demo

<!DOCTYPE html>
         .box {
            position: relative;
         img {
            width: 100%;
            height: auto;
            opacity: 0.6;
         .direction {
            position: absolute;
            top: 10px;
            left: 19px;
            font-size: 13px;
      <h1>Heading One</h1>
      <p>Below image has text in the top left:</p>
      <div class = "box">
         <img src = "" alt = "Tutorial" width = "800" height = "400">
         <div class = "direction">Top Left Corner</div>
Updated on 04-Jul-2020 06:16:38