CSS does not work outside the live preview of Brackets IDE

0
<head>
<link rel="shortcut icon" href="img/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/stylesheet.css">
<title>......</title>

I'm using Brackets to edit and have a live-preview option, which when editing updates automatically. However, I put the whole file on a local server and then realized that the CSS is not being linked.

    
asked by anonymous 20.05.2017 / 22:56

1 answer

0

Consider the following folder hierarchy:

  • Web server root (where your site is, pointed to by the domain, www.algumacoisa.com/)
    • css (folder with styles)
      • file.css (css file)
    • index.html (site file)

You can link the arquivo.css from the index.html file in the following ways:

Absolute path relative to web server root (link will be the same for every html file, regardless of location)

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

Relative path (to your index.html)

<link rel="stylesheet" type="text/css" href="css/stylesheet.css">
    
20.05.2017 / 23:17