DEV Community

Cover image for 3 Ways to Add CSS to HTML
Mohamed Amine Fh
Mohamed Amine Fh

Posted on


3 Ways to Add CSS to HTML

1. Internal

The 1st one is by placing the <style> tag in the <head> or in the <body>.

if you placed in the body make sure it's after the opening <body> tag, so your styles will run for all the elements in the body.

Internal Css

This way is not for daily use or for big projects, because the html file will be complicated more and more.

2. External

The 2nd is by creating a CSS file and link it inside your HTML .

In this example we created a CSS file named style.css and linked it using the link tag. put the path to your css file in the href.

External Css

3. Inline

The last way is the inline way. by adding the style property inside any HTML tag you want to style.

Inline Css

The common used way for daily programming is the External way

Top comments (0)

16 Libraries You Should Know as a React Developer

Being a modern React developer is not about knowing just React itself. To stay competitive, it is highly recommended to explore the whole ecosystem. This article contains some of the most useful React component libraries to speed up your developer workflow.