How to add CSS in an HTML Document. Explain different ways.

css

We can add CSS to our HTML document at three different levels:

  • Inline Styles
  • Internal Styles
  • External Styles

Inline Styles

CSS can be added directly to HTML Elements using style attributes.

<p style="color: orange"> Inline CSS set my color to Orange. </p>

Internal Stylesheet

Internal Stylesheets can be added using <style> tag.

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

External Stylesheet

External stylesheet defined inside a .css file can be added to the document using <link> tag.

<link rel="stylesheet" href="https://hackinbits.com/style.css"/>

Multiple <link> tag an be used to add different external stylesheets. Stylesheets will be applied in the order they are added to the document.

Share and support us

Share on social media and help us reach more people