CSS Introduction
What is CSS?
CSS stands for cascading style sheets.
CSS describe how HTML elements are o be displayed on screen, paper or in other media .
CSS saved a lot of work . It can control the layout of multiple web pages all at once.
External style sheets are stored in CSS files.
Why use CSS?
CSS is used to define styles for your web pages , including the design,layout and variations in display for different devices and screen sizes.
E.g:
<!DOCTYPE html>
<html>
<head>
<stye>
body
{
background-color: light blue;
}
h1
{
color: blue;
text-align: center;
}
p
{
font-family: red serif;
font-size: 20px;
}
</stye>
</head>
<p>My First CSS Example<p>
<p>>This is a paragraph<p>
</body>
</html>
Result:
CSS Syntax
The selector pints o he HTML elements you want to style.
The declaration block contains one r more declaration separated by semicolons.
Each declaration includes a CSS property name and value separated by a colon.
Multiple CSS declaration are separated with semicolons and declaration blocks are surrounded by curly braces.
E.g:
<!DOCTYPE html>
<html>
<head>
<style>
p
{
color: red;
text-align: center;
}
</style>
</head>
<body>
<p>Hello word<p>
<p>These paragraphs are styled with CSS..</p>
</body>
</html>
Result:
Example explained:
p is a selector in CSS (it points to the HTML elements you want to style:<p>).
color is a property and red is the property value.
text-align is a property and center is the property value.
Comments
Post a Comment