What is <style> tag and why it is used inside HTML document?

css

<style> tag is used to add internal stylesheet in an HTML document.

<style> tag can be added inside <head> or <body> element. But it is recommended to include them inside <head> tag for organizational purpose.

You are free to define multiple <style> elements in a single HTML document. They will be applied in the same order they are included in the document.

<!doctype html> 
<html>
  <head>
    <style>
      p {
        color: red;
      }
    </style>
  </head>
  <body>
    <p>This is my paragraph</p>
  </body>
</html>

Share and support us

Share on social media and help us reach more people