Menu Close

How to write the comments in css

comments

The comments in css are basically used to explain the purpose of the style rule declarations. It will help the others to understand what we were trying to do with the style rules at the time of the editing. The comments in the stylesheet are not displayed by the browser. Follow the below example to understand this.

Example:

<!DOCTYPE html>
<html> 
<head>
    <title>Comments In CSS</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css">
    <style>
        /* Single line comment */
        /* This is the
        multi-line comment */
        body {
            margin: 50px;
            font-family: Arial, sans-serif;
        }
        p {
            color: #000;
        }
        h2 {
            color: #000fff;
        }
    </style>
</head>  
<body>
    <section>
        <div class="container">
            <h2>Comments In CSS</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu sem tempor, varius quam at, luctus dui. Mauris magna metus, dapibus nec turpis vel, semper malesuada ante.</p>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu sem tempor, varius quam at, luctus dui. Mauris magna metus, dapibus nec turpis vel, semper malesuada ante.</p>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu sem tempor, varius quam at, luctus dui. Mauris magna metus, dapibus nec turpis vel, semper malesuada ante.</p>
        </div>
    </section>    
</body>
</html> 
Posted in CSS, HTML

You can also read...