Syntax Example For Every CSS Feature

CSS Syntnax

Following is Declaration Block.

img {
  width: 300px;
}

img is Selector. This complete line width: 300px; is called Rule. width: is Property. 300px; is Value.

Property is a style charcteristic that will be applied to selector and values are specific to the properties and varies depending upon the property.

Properties may have have shorthand and longhand syntanx.

CSS Comments

Use cases of comments.

  • Leave notes for yourself and others.

  • Organize code blocks.

  • Comment out code to hide it temorarily.

    /* Header Styles */
    header {
      width: 80%;
    }
    
        /*
        .slider {
          width: 100px;
          background: red;
        }
        */
    

Formating and Whitespace

Formating and whitespaces have no impact on working of css. To have readability format the code in a style that makes sense to you. Code Guide can be helpful tool for learning standards of formanting in HTML and CSS.

Previous
Next