Lesson 5: How To Add CSS?

الدرس 5: How To Add CSS؟

Lesson 5: How To Add CSS?

How To Add CSS?

When a browser reads a style sheet, it will format the HTML document according to the information in the style sheet.There are three ways of inserting a style sheet: External CSS - Internal CSS - Inline CSS

Example :

 <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="mystyle.css" /> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html>

 

 /* In mystyle.css */ body { background-color: lightblue; } h1 { color: navy; margin-left: 20px; } 

 

 <!-- Internal CSS --> <!DOCTYPE html> <html> <head> <style> body { background-color: linen; } h1 { color: maroon; margin-left: 40px; } </style> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html>

 

 <!-- Inline CSS --> <!DOCTYPE html> <html> <body> <h1 style="color: blue; text-align: center">This is a heading</h1> <p style="color: red">This is a paragraph.</p> </body> </html>

Important links About Us

Share with your friends

العودة إلى المقالات