Understanding the Basics : Syntax, Selectors, and Declarations

Understanding the Basics : Syntax, Selectors, and Declarations

Syntax : The structure of CSS is simple—it comprises selectors and declarations. A selector identifies the HTML element you wish to style while a declaration block consists of declarations separated by semicolons. Each declaration specifies a property and its corresponding value, in the format property; value.

Selectors : Elements in an HTML page are identified by names called selectors, which allow you to access and modify them using CSS. A variety of selection types exist:

Type selectors focus on elements in HTML such as div, h1, and p.

Class selectors preceded with a period (. ), target items with certain classes.

ID selectors focus on items that have certain IDs that are preceded by a hash (#).
 

Declarations : A declaration is a rule that establishes an element's style. Declarations, which define the attributes and values to be applied to the chosen items, are encircled by curly brackets {}.

Example of CSS Syntax


/* Selecting paragraphs to change text color and font size */
p {
    color: blue;
    font-size: 16px;
}


logo

CSS

Understanding the Basics : Syntax, Selectors, and Declarations

Beginner 5 Hours

Understanding the Basics : Syntax, Selectors, and Declarations

Syntax : The structure of CSS is simple—it comprises selectors and declarations. A selector identifies the HTML element you wish to style while a declaration block consists of declarations separated by semicolons. Each declaration specifies a property and its corresponding value, in the format property; value.

Selectors : Elements in an HTML page are identified by names called selectors, which allow you to access and modify them using CSS. A variety of selection types exist:

Type selectors focus on elements in HTML such as div, h1, and p.

Class selectors preceded with a period (. ), target items with certain classes.

ID selectors focus on items that have certain IDs that are preceded by a hash (#).
 

Declarations : A declaration is a rule that establishes an element's style. Declarations, which define the attributes and values to be applied to the chosen items, are encircled by curly brackets {}.

Example of CSS Syntax


html
/* Selecting paragraphs to change text color and font size */ p { color: blue; font-size: 16px; }


Similar Data Science Tutorials

Related tutotials

Frequently Asked Questions for css

line

Copyrights © 2024 letsupdateskills All rights reserved