There are three ways to add CSS to a webpage.
- External CSS
- Internal CSS
- Inline CSS
1. External CSS : It is a file created using any text editor and saved with .css extension. To use this file in our webpage we have to provide a link on the head section of our html file. The syntax of style sheet link is :
<link rel=”STYLESHEET” type=”text/css” href=”URL of style sheet”>
<link rel=”stylesheet” type=”text/css” href=”style.css”>
In the above example style.css is the name of style sheet and it is present in current directory. If it is present in other directory then we have to mention it.
2. Internal CSS : When CSS elements are written with in HTML file it is called as internal CSS. It is written with in HEAD section of HTML document. It is enclosed with open and closing <style> element.
3. Inline CSS : When we use style attribute with in any HTML opening tag to specify the style of only that element, then it is called inline CSS.
Example : <h1 style=”color:red;”>Heading </h1>
In this course we will discuss about internal CSS only.