Open In App

How to Create Style Labels using HTML and CSS ?

Last Updated : 16 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Creating style labels using HTML and CSS involves designing form labels that enhance user interaction. By applying CSS properties like color, font, and spacing, you can improve the appearance of labels associated with input fields, making forms more visually appealing and user-friendly.

Creating Styled Labels with HTML and CSS

This approach utilizes HTML div elements with CSS classes to create visually distinct labels for different statuses. By applying background colors and styles, you enhance the user interface, making important messages like success, alert, and warning more noticeable.

Example: In this example, we will creates styled labels for success, alert, and warning messages. Each label has distinct background colors and text styles for easy identification and emphasis.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        How to Create Style Labels
        using HTML and CSS?
    </title>

    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
        }

        .label {
            font-size: 1.5rem;
            padding: 0.5rem;
            margin-bottom: 10px;
            display: inline-block;
            border-radius: 3px;
        }

        .success {
            background-color: #28a745;
            color: #fff;
        }

        .alert {
            background-color: #dc3545;
            color: #fff;
        }

        .warning {
            background-color: #ffc107;
            color: #212529;
        }
    </style>
</head>

<body>
    <div class="label success">
        Success
    </div>

    <div class="label alert">
        Alert
    </div>

    <div class="label warning">
        Warning
    </div>
</body>

</html>

Output:

style-labels


Next Article

Similar Reads