Lesson 2: Ways to Apply CSS

Inline CSS

Applied directly to an HTML element:

<p style="color: red;">This is a red paragraph.</p>

Internal CSS

Written inside a <style> tag in the <head> section:

<style>
  p {
    color: green;
  }
</style>

External CSS

Written in a separate file and linked to the HTML document:

<!-- Link in your HTML file -->
<link rel="stylesheet" href="styles.css">

Example of styles.css:

body {
  background-color: lightyellow;
  font-family: Arial, sans-serif;
}
h1 {
  color: darkblue;
}

External CSS is the preferred method as it keeps your code organized and reusable.