Open In App

How to Create a Cutout Text using HTML and CSS ?

Last Updated : 12 Jul, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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:

HTML




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


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 knowledge. 

  • CSS Code:

CSS




<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>


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

HTML




<!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">
 
        <!-- Cutout text -->
        <h1 class="text">
            GeeksforGeeks
        </h1>
        <p>
            "A Computer Science Portal<br>
            for Geeks"
        </p>
    </div>
</body>
 
</html>


Output: 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads