We can write a CSS 3 ways in HTML
👉Inline CSS:
- Description: Applied directly within HTML tags using the
style
attribute. - Use Case: Ideal for small-scale styling adjustments on specific elements.
- Example:
<p style="color:blue; font-size 16px;"> This is Inline css </p>
👉Internal or Embedded CSS:
- Description: Placed within the
<style>
tags in the HTML<head>
section. - Use Case: Suited for styling a specific webpage; allows for a balance between specificity and reusability.
- Example:
- <head>
- <style>
- h1{color:green;}
- p{font-size: 16px;}
- </style>
- </head>
👉External CSS:
- Description: Defined in a separate CSS file and linked to HTML using the
<link>
tag. - Use Case: Promotes reusability across multiple pages; facilitates a centralized approach to styling.
- Example (HTML):
- <head>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
Comments
Post a Comment