The source of the image
is wrong.
You can either user Absolute Path
or Relative Path
- Absolute V/s Relative Path
Use Relative Path as they are not bound to a base URL
Now coming back to your problem, file://bg.jpg
is not a valid path.
As you have given the structure of your project let us consider that you wanted the background image
and <img />
in file index.html and image bg.jpg are both in the same directory.
Which mean if your files structure
is like this
project_folder
|
index.html
| main.js
| bg.jpg
Then instead of file://bg.jpg
use bg.jpg
.
Thus you code become like
<img src="bg.jpg" width="50px" height="50px">
...
body{ background-image: url('bg.jpg') 50px 50px repeat; }
NOTE: Only valid if both HTML file and image are in the same directory
If not then you have to use a relative
path to access the image