CSS Syntax

Next ❯CSS Selectors

CSS Syntax consists of a selector and a declaration block

  • turned_in_notSyntax
    selector {
      property1: value1;
      property2: value2;
      .................;
      .................;
      propertyN: valueN;
    }
Example:
  • turned_in_notSyntax Sample
  • trending_downSyntax Description
    • Selector : Element/Tag you want to style
    • Declaration Block : Contains one or more declarations separated by semicolons (;) inside curly brackets
    • Property : Specific property to the HTML elements
    • Value : Value to the specific property

CSS Comments

Mainly helpful to the programmer or can say developer for modifications if required later, used to explain the code

  • Syntax: /* Your comment */
  • Ignored by browsers
Example:
  • turned_in_notSingle Line Comment
    p {
      color: red;
      /* This is a single-line comment */
      text-align: center;
    }
  • label_outlineMulti Line Comment
    p {
      /* This is
      a multi-line
      comment */
      font-size: 10px;
    }

  • CSS Selectors
❮ Prev Introduction
Next ❯CSS Selectors
TryOut Examples"Learn to Explore..!"

TryOut Editor

receipt