You can apply CSS styles to a web page using 3 ways:
Inline CSS - You can apply CSS style inside the HTML tags(elements) that are called inline CSS.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Inline CSS</title>
</head>
<body>
<p style="color:#E80A0E;font-size:14px;">This is Inline CSS Example.</p>
</body>
</html>
Internal Style Sheet : You can apply CSS styles Inside <head> section in HTML using <style></style>.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Internal CSS</title>
<style type="text/css">
p {
color:#E80A0E;
font-size:14px;
}
</style>
</head>
<body>
<p>This is Internal Style Sheet Example.</p>
</body>
</html>
External Style Sheet: Create another file save it with .css extension and then link this css file using <link>.
<!-- example.html -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>External CSS</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<p>This is External Style Sheet Example.</p>
</body>
</html>
// styles
p {
color:#E80A0E;
font-size:14px;
}
The main benefit of setting class or ID is that you can present the same HTML element differently, depending on its class or ID
Comments
Leave a comment