css-syntax-css-tutorials.png

CSS Syntax Structure and Rules Full Explanation with Examples - Css Tutorials

A CSS style sheet consists set of instructions written in inline HTML or an external CSS file linked in an HTML file, which is interpreted by web browsers such as Chrome, Firefox, Microsoft Edge, etc, and after interpreted instructions are applied to the corresponding element of HTML. Such as - paragraph, heading, div, etc. You can style html element by giving any instructions so that it looks attractive. You can style important elements of your html web pages something creative that grabs the attention of your users. There are some CSS structures and CSS rules that are used to give style to the html element. you have to follow these CSS structures and rules to style HTML elements. 

CSS Syntax Structure and Rules 

CSS syntax Structure is made of three major parts these are:-

Selectors: - A Selector is an HTML tag on which the CSS Style Sheet will be applied. Like :- <h1>, <p>, <span> etc.

Property: - A property is a type of attribute of the HTML elements. Such as Color, border, etc. 

Value: - Value is assigned on the CSS Property. For example, Color is the property and red is the value that is assigned to the color attribute. 

Syntax of CSS


Let us see through with a simple example.


h1{
color: Red;
background-color: Yellow;
}
p{
color: Yellow;
background-color: green;
}

<h1> This is a Heading. </h1>
<p> This is a Paragraph. </p>

Output: -