Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Ive created a separate folder called css and created a styles.css page within it. Please let me know why my preview page is not showing my css now.

<!DOCTYPE html>
<html>

    <head>
    
      <meta charset="utf-8">
      <meta name="description"Yasin Zahir>
      <title>Yaso's Personal Site</title>
      <link rel = "stylesheet"
      type = "text/css"
      href = "styles.css" />
    </head>
question from:https://stackoverflow.com/questions/65661422/why-is-my-html-link-to-external-css-not-working

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
78 views
Welcome To Ask or Share your Answers For Others

1 Answer

You have tow options for inclusion path:

  1. Relative
  2. Fix

Relative#Sample 1

 -root directory
 -css
  stylesheet.css
 -index.html

    <link rel='stylesheet' type='text/css' href='css/stylesheet.css'>

Relative#Sample 2

-root directory
 -css
   stylesheet.css
 -html
   index.html

    <link rel='stylesheet' type='text/css' href='../css/stylesheet.css'>

Fixed#Sample

-root directory
 -css
   stylesheet.css
 -html
   index.html

    <link rel='stylesheet' type='text/css' href='[root directory]/css/stylesheet.css'>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...