How to add css to html – Code Example

Total
0
Shares

In this article we will provide you code to add css to html files. You can add css styles using <style> tag. To add external css file, you can use <link> tag with href=stylesheet path.

Code Example –

1. Adding css styles to html –

<!DOCTYPE HTML>
<html>
  <head>
    <style>
       // Add your css here
    </style>
  </head>

  <body></body>
</html>

2. Adding external stylesheet to html –

<!DOCTYPE HTML>
<html>
  <head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.0/css/bootstrap.min.css" />
  </head>

  <body></body>
</html>

3. Adding local stylesheet file to html –

<!DOCTYPE HTML>
<html>
  <head>
    <link rel="stylesheet" href="/stylesheet_absolute_path.css" />
  </head>

  <body></body>
</html>