How To Add CSS
There are three ways to insert CSS in HTML documents.
- Inline CSS
- Internal CSS
- External CSS
1) Inline CSS :
Inline CSS is used to apply style on a single line or element.
Example :
file name - index.html
This will produce the following result −
2) Internal CSS :
Internal CSS is used to apply CSS on a single document or page.
It is written inside the <style> tag within head section of html. Rules defined using this syntax will be applied to all the elements available in the document.
Example :
file name - index.html
This will produce the following result −
3) External CSS :
External CSS is used to apply CSS on multiple pages or all pages.
We write all the CSS code in a separate CSS file. Its extension must be .css for example style.css
This CSS file should be linked to html pages using <link>tag in <head>section.
Example :
file name- index.html
file name - style.css
This will produce the following result −