How to write comments in CSS?

How to write comments in CSS?

Asked on October 30, 2018 in HTML / CSS.
Add Comment


  • 2 Answer(s)

     Use the Syntax “/* text */”
    For explaining the purpose of the style rules declarations, comments in css are used.
    It will to understand what you were trying to do with the style rules at the time of editing style sheets.
    Comments are not displayed by the browsers.

    A CSS comment begins with /*, and ends with */.
    For example:

    /* This is a single line CSS comment */
    /* This is an example of a
    CSS multi-line comment */
    body {
        font-family: Arial, sans-serif;
    }
    p {
        color: #333;
        line-height: 1.5;
    }
    
    Answered on October 30, 2018.
    Add Comment

    With a proper structure, comments make it a breeze to navigate and locate the sections in your page, e.g.

    /***************
     * UI Elements *
     ***************/
    h1, h2, h3, p {
        ...
    }
    table, form, input, textarea {
        ...
    }
    
    /* Custom Radio button hack: use background-image/position on label */
    input[type=radio] {
        display:none; 
    }
    input[type=radio] + label {
        background-image: url(...);
    }
    input[type=radio]:checked + label {
        background-image: url(...);
    }
    
    
    /**********
     * Header *
     **********/
    #site-header {
        ...
    }
    #logo {
        ...
    }
    
    /***********
     * Sidebar *
     ***********/
    
    Answered on February 24, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.