

- #HOW TO PUT BACKGROUND IMAGE IN HTML FROM A FOLDER HOW TO#
- #HOW TO PUT BACKGROUND IMAGE IN HTML FROM A FOLDER CODE#
- #HOW TO PUT BACKGROUND IMAGE IN HTML FROM A FOLDER WINDOWS#
It’s so weird to see a directory called c:\ and type the ‘\’ key without first pressing shift :) Įdit: An absolute filepath would probably work on a *Nix system and might work on a Windows system if done correctly… I’ve just never tried because there’s no point really. Not sure if that’s going to work but that’s how *Nix systems do it.

Your stylesheet needs to know to look beyond the css directory it’s in and go looking up in c:\ or ‘down’ in c:\ I’m not really certain of the syntax, but you need to jump up a level in the file system or go one deeper, whatever you prefer. Now, would it do you more good for me to say “It’s at the SE corner of Washington and 4th” or would it be better for me to say “From where you’re standing, you need to head into the sunset for 200 yards?” Obviously the latter… provided you didn’t have a smartphone… which your stylesheet doesn’t.
#HOW TO PUT BACKGROUND IMAGE IN HTML FROM A FOLDER HOW TO#
Imagine you’re standing on some nondescript street corner in a city you don’t know and I’m telling you how to get to your car. That is, a file path that points to the location of the image RELATIVE to the document requesting it. Ok… here’s the problem: Your stylesheet has no idea where c:\f.jpg is. To add a background-image to a section tag in your. You must supply the location of the image, either as an absolute URL or a relative URL. Right-click the image (control-click on Mac) and select 'Copy Image Location.' You can also click 'View Image' to see the image alone on a page, then copy the URL in your address bar. The above example uses the background-image property to set the background image. Visit the web page where your image is hosted. This could either be the whole page (by using the body selector in CSS which targets the element in our HTML), or just a standalone specific part of the page such as a section element like in the example below. To set a background image in HTML, use the CSS background-image property or the background shorthand property. The background-image CSS property allows you to then place the image behind any HTML element you wish. The first step is to make sure you create an assets directory (folder) to hold the images you want to use in your project.įor example we can create an images folder in the project we are working on and add an image called sunset.png that we want to use.
#HOW TO PUT BACKGROUND IMAGE IN HTML FROM A FOLDER CODE#
This article explains how to add images to your HTML code and how to then fine-tune them to look better. Modern browsers support a variety of image file types like. It will also affect how easily they can use the whole site in general.Īdding images to the background of certain parts of a website is often more visually appealing and interesting than just changing the background-color.

Browse to europaheader.jpg in the images folder and click Open. Find the section / - Step 1: Start Here - / and add the background-image property to headerimg CSS selector. Try this: background-image: url ('.\f.jpg') Not sure if that’s going to work but that’s how Nix systems do it. Use CSS to set images used for style or decoration, such as background or header images. Your stylesheet needs to know to look beyond the css directory it’s in and go looking up in c:\ or ‘down’ in c:\. What a user sees on a website will impact how good their user experience is. Here is your stylesheet: c:\css\lemonstyle.css.
