How to Create a Cutout Text using HTML and CSS ?

Cutout text is used as a background header of the webpage. The cutout text creates an attractive look on the webpage. To create a cutout text we will use only HTML and CSS. We display the cutout text and then we make the text blending of an element’s background with the element’s parent. The CSS mix-blend-mode property is required to do that. Divide this article into two sections creating structure and then we will apply CSS on that structure.

Creating Structure: In this section we will only make the cutout text structure by using HTML.

  • HTML Code:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
      
    <head>
        <title>
            Creating Cutout text with HTML and CSS
        </title>
      
    </head>
      
    <body>
        <div class="container">
              
            <!-- Cotout tex -->
            <h1 class="text">GeeksforGeeks</h1>
            <p>
                "A Computer Science Portal<br>    
                for Geeks"
            </p>
        </div>
    </body>
      
    </html>

    chevron_right

    
    

Designing the Structure: In this section we will apply some CSS property on created cutout text structure. The CSS mix-blend-mode property will play the main role and other things are totally depends on your designing knowldge.

  • CSS Code:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <style>
              
        /* container class styling */
        .container {
                  
            /* Background image */
            background-image: url(
            background-size: cover;
            height: 360px;
            position: relative;
            text-align: center;
        }
              
        /* Cutout text class styling */
        .text {
            background-color: black;
            color: white;
            font-size: 68px;
            font-weight: bold;
            margin: 0 auto;
            padding: 15px;
            border: 5px solid gray;
            position: absolute;
            top: 25%;
            left: 23%;
            mix-blend-mode: multiply;
        }
              
        .text:hover {
        }
              
        /* Styling p tag element */
        p {
            position: absolute;
            left: 58%;
            top: 58%;
            color: white;
            text-align: right;
            font-style:italic;
              
        }
    </style>

    chevron_right

    
    

Final Solution: In this section we will combine the HTML and CSS file together and create a cutout text for the header of webpage.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        Creating Cutout text with HTML and CSS
    </title>
    <style>
          
        /* container class styling */
        .container {
              
            /* Background image */
            background-image: url(
            background-size: cover;
            height: 360px;
            position: relative;
            text-align: center;
        }
          
        /* Cutout text class styling */
        .text {
            background-color: black;
            color: white;
            font-size: 68px;
            font-weight: bold;
            margin: 0 auto;
            padding: 15px;
            border: 5px solid gray;
            position: absolute;
            top: 25%;
            left: 23%;
            mix-blend-mode: multiply;
        }
          
        .text:hover {
        }
          
        /* Styling p tag element */
        p {
            position: absolute;
            left: 58%;
            top: 58%;
            color: white;
            text-align: right;
            font-style:italic;
          
        }
    </style>
</head>
  
<body>
    <div class="container">
          
        <!-- Cotout tex -->
        <h1 class="text">GeeksforGeeks</h1>
        <p>
            "A Computer Science Portal<br>    
            for Geeks"
        </p>
    </div>
</body>
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.