CSS-Cascading Style Sheets
CSS-Cascading Style Sheets
CSS-Cascading Style Sheets
• External CSS
• Internal CSS
• Inline CSS
CSS Syntax
</body>
</html>
CSS class Selector
</body>
</html>
CSS class Selector:Example 2
• In this example only <p> elements with class="center" will be red and center-aligned:
<!DOCTYPE html>
<html>
<head>
<style>
p.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
</body>
</html>
CSS class Selector:Example 3
• In this example the <p> element will be styled according to class="center" and to class="large":
<!DOCTYPE html>
<html>
<head>
<style>
p.center {
text-align: center;
color: red;
}
p.large {
font-size: 300%;
}
</style>
</head>
<body>
<h1>Hello world!</h1>
• The grouping selector selects all the HTML elements with the same style
definitions.
• In this example, the h1, h2, and p elements have the same style definitions:
h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
p {
text-align: center;
color: red;
}