Hi! What difference between: <img src="image.jpg">
and <img src="image.jpg" />
Same situation with and other elements without closing tags.
I google it and realized that the element with “/” matches XHTML standart. But is it still ok to use such elements without “/”?
The usage of the slash character in empty elements (also called void elements) is optional.
It’s similar with the url() CSS function. The quotes are optional as long as there aren’t any un-escaped special characters. To make your live easier I recommend to always use quotes to be safe.
From url() - CSS: Cascading Style Sheets | MDN :
A url, which is a relative or absolute address, or pointer, to the web resource to be included, or a data uri, optionally in single or double quotes. Quotes are required if the URL includes parentheses, whitespace, or quotes, unless these characters are escaped, or if the address includes control characters above 0x7e. Double quotes cannot occur inside double quotes and single quotes cannot occur inside single quotes unless escaped. The following are all valid and equivalent:
If you choose to write the URL without quotes, use a backslash ( \ ) before any parentheses, whitespace characters, single quotes ( ' ) and double quotes ( " ) that are part of the URL.
It’s a bit unfortunate that we see both versions on MDN. But that happens when a lot of people over several years edit MDN.