- Inline CSS
- Internal CSS and
- External CSS
Inline CSS is used to insert a style sheet for only a single element. In an inline CSS, the style sheet affects only a single line or single element. The "style" attribute is used to define inline CSS.
Example: Inline CSS
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <h1 style="color: blue; font-size: 30px; width: 200px; border: 2px solid tomato;">Hello World!</h1> </body> </html>
Hello World!
Internal CSSInternal CSS is used to apply CSS to a document or a page. It can affect anything on the page. Internal CSS is Added inside head sections of an HTML page with <style> tag. To select the elements that we want to style on an HTML page we use CSS selectors.
Example: Internal CSS
<!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> h1{ color: blue; font-size: 30px; width: 200px; border: 2px solid tomato; } </style> </head> <body> <h1>Hello World!</h1> </body> </html>
Hello World!
External CSS is used to style multiple HTML pages by importing External CSS. The CSS document must be saved with the .css file extension separately from the Html document. The <link> tag is used to link or import external CSS documents.
Syntax
<link rel="stylesheet" type="text/css" href="css_document_name.css">
CSS document with the filename "style1.css"
h1{ color: blue; font-size: 30px; width: 200px; border: 2px solid tomato; }
<!DOCTYPE html> <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="style1.css"> </head> <body> <h1>Hello World!</h1> </body> </html>
0 Comments