Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

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 aCSS file and link it inside yourHTML .

In this example we created a CSS file namedstyle.css and linked it using thelink tag. put the path to your css file in thehref.

External Css

3. Inline

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

Inline Css

The common used way for daily programming is theExternal way

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Passionate software developer 💻
  • Location
    Tunisia
  • Education
    Self-Taught
  • Work
    Fullstack software developer
  • Joined

More fromMohamed Amine Fh

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp