Background URL CSS - For image relative, absolute path
A style sheet can reference URLs or links to other files, almost always it is images that are linked as background or fonts.
In the case, rare, that in a style sheet should reference URLs or links to other files , almost always it is about graphics that are linked as background to an element. In this case, a particularity must be taken into account:
In CSS, URLs are always defined with reference to the style sheet, not the document linked to it.
The proper directory structure could be, for example:
file.html
images/imagen.gif
css/your-stylesheets.css
Therefore, if you want to integrate a background image on your page, the CSS file will appear, for example:
body {
background-image: url (../imágenes/imagen.gif);
/* otras declaraciones */
}
You can clearly see that the trajectory of the image, after the initial URL, is written in parentheses ().
Of course you can also use absolute URLs instead of relative.
body {
background-image: url (http://www.dominio.es/imagenes/imagen.gif);
/* other statements */
}
In theory, the URL itself can be written in quotes, double or single. Although it can also cause an error message (depending on the navigator). IE / MAC, for example, does not accept single quotes in URLs.
ChatGPT Free
Ask questions on any topic
CITE ARTICLE
For homework, research, thesis, books, magazines, blogs or academic articles
APA Format Reference:
Delgado, Hugo. (2019).
Background URL CSS - For image relative, absolute path.
Retrieved Nov 03, 2024, from
https://disenowebakus.net/en/url-css