CSS stands for Cascading Style Sheets is used to style and layout web pages.
CSS used in HTML pages by three ways-
1)-Inline style - Using the style attribute in the HTML start tag.
2)-Embedded style - Using the <style> element in the head section of the document.
3)-External style - Using the <link> element, pointing to an external CSS files.
Inline Styles
Inline styles are used to apply the unique style rules to an element, by putting the CSS rules directly into the start tag.
It can be attached to an element using the style attribute.
Example
<html>
<head>
</head>
<body>
<p style="background-color:red;">This is a paragraph.</p>
<p style="background-color:green;">This is a paragraph.</p>
</body>
</html>
Embedded style
Embedded style sheets are defined in the <head> section of an HTML document using the <style> tag.
You can define any number of <style> elements inside the <head> section.
Example
<html>
<head>
<style>
body { background-color: green; }
p { color: red; }
</style>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
External Style
An external style sheet is applied to many pages.
Example
<html>
<head>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
Copyright ©2022 coderraj.com. All Rights Reserved.