What are these two points at the beginning of a URL in CSS? [duplicate]

0

I created a css sheet, linked to the html to format it, after many attempts the code only accepted the formatting after I left it like this:

h1 {
    background-image: url(../img/sobre-background.jpg);
}

However, I do not understand the 2 points at the beginning, since it does not have a folder or path with those 2 points !!

    
asked by anonymous 29.01.2018 / 23:33

3 answers

3

The ../ returns 1 level in the directory tree, just like ../../ returns 2 levels etc.

The url(../img/sobre-background.jpg) path will look for the sobre-background.jpg file within the img folder within the parent folder of the document that is calling the file.

    
30.01.2018 / 00:16
1

The colon is to indicate that a level will descend in the folder hierarchy.

Your css is probably in a css folder:

  

css

     
    

file.css

  
     

index.html

     

img

     
    

image.jpg

  

When you give the command ../ you indicate that you are going down one level in the folder and going to the img folder.     

29.01.2018 / 23:44
1

This is called a relative path !

What you did ( url(../img/sobre-background.jpg) ) will consider the image in the previous directory.

Suppose you have the following directory structure:

  
  • home directory      
    • index.html
    •   
    • css      
      • main.css
      •   
    •   
    • img      
      • sobre-background.jpg
      •   
    •   
  •   

If you use the colon in a CSS url, it means that it will return a directory.

To learn more, I suggest you read:
- > link

    
29.01.2018 / 23:44