How HTML and CSS Work Together

  • HTML gives the structure (where the text, images, etc. go).
  • CSS gives the style (how it looks – color, size, layout).

Example in action:

htmlCopy code<!DOCTYPE html>
<html>
<head>
  <style>
    body {
      background-color: lightgray;
    }
    h1 {
      color: darkblue;
      text-align: center;
    }
    p {
      color: black;
      font-size: 18px;
    }
  </style>
</head>
<body>

<h1>Welcome to My Website</h1>
<p>This is a paragraph styled with CSS.</p>

</body>
</html>