Home > Blockchain >  html linking , relative path
html linking , relative path

Time:02-03

i cant connect stylesheet to my html file, i cant inport image from my pc by realtive path. I have seen lot of questions here and i tried all the suggestions but i didnt found a solution, im 100% sure my syntax is right. Its wierd because i can inport images from url. It seems like my pc have some problem with relative paths, or it may be some wierd setting in my VS code. Can i get some advise to solve this, what should i try.

Here is some example...

        <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <link rel="stylesheet" href="templates/style.css">
    </head>
    <body> 

    </body>
    </html>

i have tried all variations like href="style.css", href="./style.css"

CodePudding user response:

Your code is valid, but you might be mistaken in the location of the files your linking to. That would result in an invalid url.

Have a look at a folder structure as below. You've got a project folder name project-example this folder contains the index.html and the folders templates and images.

If you want to link in your index.html to the files in those folders the src or href would have to be something like templates/style.css or images/image.png.

example of a folder structure

  •  Tags:  
  • Related