0

Linking CSS to HTML

February 13, 2023
Share

Before you start adding all sorts of styles to your HTML, you need to link the two together. Think of linking CSS to HTML as a dance between beauty and functionality. 💃🕺 Your HTML provides the structure and content for your website, while your CSS adds the pizzazz and style. Together, they create a seamless and beautiful web experience for your users.

So, how do you link CSS to HTML? It’s simple! There are three ways to link CSS to HTML:

  1. External Stylesheet: This method involves creating a separate CSS file and linking it to your HTML file using the link element in the head section of your HTML file. It is the recommended method because it makes CSS manageable. For example:
<head>
  <link rel="stylesheet" type="text/css" href="style.css">
</head>
  1. Internal Stylesheet: This method involves adding CSS styles directly to the head section of your HTML file using the style element. For example:
<head>
  <style>
    h1 {
      color: blue;
    }
  </style>
</head>
  1. Inline Styles: This method involves adding CSS styles directly to an HTML element using the style attribute. For example:
<h1 style="color:blue;">Hello World!</h1>

And that’s it! You’re now ready to add some style to your HTML. 🎨 Just remember to keep your CSS organized and well-commented, so you can easily make changes to your styles in the future.

So, what are you waiting for? It’s time to link up and dance the night away! 💃🕺 Happy styling!