-1

I've seen the option where URL in SCSS was specified without quotes like background: url(/path/to/image.jpg);. However, I'm using this with quotes background: url(/path/to/image.jpg); and this works although PhpStorm stresses these URLs due to problems with directory resolve.

Is there any difference between both options? Should be any used instead of another? Just in case this would help - I'm storing my images in assets sub folders.


This is not just about CSS it's about SCSS therefore I'm sure that question which is marked as duplicate of is no suitable for my question.

SCSS works in different way since it should be compiled before. If there is a wrong URL a compiler would throw an error about path resolving problem. Also, Angular moves assets from their initial positions. That's why I'm asking.

Sergey
  • 7,184
  • 13
  • 42
  • 85
  • Possible duplicate of [Is quoting the value of url() really necessary?](https://stackoverflow.com/questions/2168855/is-quoting-the-value-of-url-really-necessary) – sandrooco Feb 19 '19 at 09:34

1 Answers1

-1

Quotes are optional.

You need them only when you want to add special characters or the component variables like below.

For eg:

 [ngStyle]="{ 'background-image': 'url(' + image + ')'}"> 

where image is a component variable

dileepkumar jami
  • 2,185
  • 12
  • 15
  • I've asked about SCSS. Not template – Sergey Feb 19 '19 at 12:54
  • I have just shown a usage of `url()`. where quotes are must. It happened that it is in the template. Also, my answer has clearly mentioned when you need it and when not. This does not deserve a downvote – dileepkumar jami Feb 19 '19 at 12:56