Inline CSS : When you want to give a look, to one element in an HTML document you can use inline styles. These styles are applied directly within the elements style attribute.
Example of Inline CSS:
<p style="color: red; font-size: 20px;">This is a paragraph with inline CSS.</p> |
Internal CSS : Internal styles, also called embedded CSS are defined inside the <style> tag within the <head> section of an HTML file. This approach is handy, for maintaining styles across a webpage.
Example of Internal CSS:
<head> <style> body { background-color: lightblue; } h1 { color: navy; } </style> </head> <body> <h1>Welcome to My Site</h1> <p>Body text styled with internal CSS.</p> </body> |
External CSS : On the hand external styles are stored in a CSS file and linked to the HTML document using the <link> tag. This method works best when you need to apply the styles across pages on a website.
Example of External CSS:
<head> <link rel="stylesheet" href="styles.css"> </head> <body> <h1>Heading Styled from External CSS</h1> <p>Paragraph styled from the external CSS file.</p> </body> |
And this is what styles.css would contain
h1 { color: darkgreen; } p { color: darkblue; } |
Inline CSS : When you want to give a look, to one element in an HTML document you can use inline styles. These styles are applied directly within the elements style attribute.
Example of Inline CSS:
<p style="color: red; font-size: 20px;">This is a paragraph with inline CSS.</p> |
Internal CSS : Internal styles, also called embedded CSS are defined inside the <style> tag within the <head> section of an HTML file. This approach is handy, for maintaining styles across a webpage.
Example of Internal CSS:
<head> <style> body { background-color: lightblue; } h1 { color: navy; } </style> </head> <body> <h1>Welcome to My Site</h1> <p>Body text styled with internal CSS.</p> </body> |
External CSS : On the hand external styles are stored in a CSS file and linked to the HTML document using the <link> tag. This method works best when you need to apply the styles across pages on a website.
Example of External CSS:
<head> <link rel="stylesheet" href="styles.css"> </head> <body> <h1>Heading Styled from External CSS</h1> <p>Paragraph styled from the external CSS file.</p> </body> |
And this is what styles.css would contain
h1 { color: darkgreen; } p { color: darkblue; } |
Copyrights © 2024 letsupdateskills All rights reserved