Home HTML Tutorial for beginners 12 How to add CSS to webpage

12 How to add CSS to webpage


There are three ways to add CSS to a webpage.

  1. External CSS
  2. Internal CSS
  3. 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”>

Example :

<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.


Please enter your comment!
Please enter your name here