In this CSS section, we will learn the syntax of CSS
CSS syntax or rule-set is consists of a selector and declaration block.
Let's see one by one:
Selector:
Indicates the element you want to add style
Declaration Block:
It contains one property and one value
Property:
Property is an attribute, it could be color, border etc.
Value:
Values are assigned to CSS properties.
CSS comments:
CSS comments are used to specify what’s the code all about and for future understanding.
CSS supports both single-line comments and multiple line comments. A CSS comment starts with /* and ends with */. Comments can also span multiple lines:
Example:
<!DOCTYPE html>
<html>
<head>
<style>
p {
color: red;/* Define color red for all <p> tag */
text-align: center;
}
h1 {
text-align: center;
/* color: red;
font-wight: 500;*/
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>This paragraph is styled with CSS.</p>
<p>CSS comments are not shown in the output.</p>
</body>
</html>
May this example help you