Careeroza
CSS Syntax
A CSS Rule
A rule consists of a selector and a declaration block:
h1 {
color: blue;
font-size: 24px;
}- The selector (
h1) points to the HTML elements to style. - The declaration block contains one or more declarations separated by semicolons.
- Each declaration has a property (
color) and a value (blue), separated by a colon.
Example
Example
All <p> elements are centered and red:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
p {
color: red;
text-align: center;
}
</style>
</head>
<body>
<p>Hello World!</p>
<p>These paragraphs are styled with CSS.</p>
</body>
</html>Result