Adding an image in HTML from a different drive - step-by-step guide!

Currently, I am immersing myself in HTML, CSS, and JavaScript as I gear up for my upcoming school project centered around frontend development. Here's the issue I encountered.

While attempting to insert an image into one of my HTML files, I ran into a dilemma. The image was stored on drive C: while the HTML file resided on drive E:. In my attempt, I utilized an <image> tag.

practice.html:

E:\Frontend-Notes\Mainpage\practice.html

10-11.jpg:
C:\Users\wangz\Pictures\WallPaper\Scenery\10-11.jpg

   <image src = "C:\Users\wangz\Pictures\WallPaper\Scenery\10-11.jpg">

After ctrl+clicking the supposed absolute path, I was met with an error message in VS code as shown below. error message

I'm at a loss on how to resolve this issue.

Answer №1

To tackle your issue, there are a couple of solutions you can try: 1. Move your 10-11.jpg file to your project folder located at E:\Frontend-Notes\Mainpage

2. Alternatively, you can specify the address in src as shown below:

file:///C:\Users\wangz\Pictures\WallPaper\Scenery\10-11.jpg

Hopefully, one of these methods will work for you.

Answer №2

One simple solution is to relocate the desired image to the same folder as your project or to create a dedicated image folder within your project directory. Not only does this enhance organization, but it also promotes better project file management.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

AngularJS templateUrl versus template: what's the difference?

When it comes to routing, I believe that templateUrl is the preferred choice over template. However, when dealing with directives, the decision between using templateUrl or template can be a bit more nuanced. Some developers opt to include chunks of HTML i ...

Can flex-basis be used with percentage in IE11?

Encountering an issue with flexbox and IE10/11. Trying to utilize min-width/max-width values, but IE11 is not cooperating. Discovered flex-basis and used a percentage value, which functions as intended in Chrome but fails in IE11. Experimented with adding ...

Is it possible for a mobile device to play .ogg videos?

Currently, I am setting up a server to stream videos using HTML. So far, I have tested playing both .mp4 and .ogg video formats on my computer successfully. However, when I attempted to play the same videos on a mobile device, only the .mp4 file showed u ...

Improved method for categorizing items within an Array

Currently working on developing a CRUD API for a post-processing tool that deals with data structured like: { _date: '3/19/2021', monitor: 'metric1', project: 'bluejays', id1: 'test-pmon-2', voltageConditio ...

The onChange function in React JS for a Material UI 'number' TextField retains the previous value

In this element, I have an onChange function: <TextField id="rowinput" type="number" defaultValue={this.defaultRows} // defaultRows = 1 inputProps={{ min: "1", max:"5"}} onChange= ...

Scroll automatically to the following div after a brief break

On my website, the title of each page fills the entire screen before the content appears when you scroll down. I am interested in adding a smooth automatic scroll feature that will transition to the next section after about half a second on the initial "ti ...

In my chat application, I encountered the error message "Received an expression instead of an assignment or function call - no-unused-expressions"

While working on my React Chat app and trying to access my Firebase, I encountered the error message: "Expected an assignment or function call and instead saw an expression no-unused-expressions" The error seems to be related to the assignment of this.rem ...

Attempting to employ jQuery to generate a text input that allows for inputting multiple incorrect answers

I am putting together a webpage for a friend who has allergies. The idea is that users can input a food item, and the page will indicate whether or not my friend is allergic to it. I have compiled an array of his food allergies, and the goal is for the pag ...

Is it necessary for HTML "buttons" to follow the same box-model as other elements?

I recently encountered an issue with the button element and the input element when using a type of button. In both Firefox and Chrome, I noticed a behavior that seems like a bug in recent releases. However, as form elements often have exceptions to W3 rule ...

Updating button color dynamically using Angular 2

I am working on a project using angular 2 and typescript. I am looking to customize the background color of my buttons based on a variable. <div> <button md-button>1. Choose travel</button> <button md-button>2. Choose seats< ...

Changing the image's flex-grow property will take precedence over the flex settings of other child

This is the error code I am encountering, where "text1" seems to be overridden <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <!--mobile friendly--> <meta name="view ...

Utilize a standard JavaScript function from a separate document within a function of a React component

I am facing an issue where I need to incorporate a standard JavaScript function within a React component function. The script tags are arranged in the footer in the following order: <script src="NORMAL JAVASCRIPT STUFF"></script> // function ...

Guide on converting a date input to a timestamp

I am trying to convert the date retrieved from an HTML5 date input into a timestamp and store it as a variable. HTML: <form> <section class="input"> <input type="date" id="date" name="maintenanace_date"/> </section> <sectio ...

excess white space appears in the mobile version

I recently completed a website using both materializecss and bootstrap platforms. While I know this may not be the best practice, it worked for my needs. However, I am facing an issue with the mobile view. When I reduce the viewport size, a margin appear ...

Error: The iOS 14.2 system is unable to locate the variable "webkit."

Currently, I am developing a web application using AngularJS 1.7. The app runs smoothly on Safari with iOS versions 12, 14.0, and 14.1. However, upon upgrading my iOS to version 14.2/14.3 (tested on both), I encountered the following error: Error: Referen ...

jquery allows you to toggle the visibility of content

There are two divs with a button positioned above them. Initially, only one div, the catalogusOrderBox, is visible. When the button named manualButton is clicked, it should display the manualOrderBox div while hiding the catalogusOrderBox div. The text on ...

Encountering an 'Unknown provider' error while running a unit test with AngularJS and Jasmine

I am facing an issue while writing a unit test for a controller in my application. Jasmine is showing an 'Unknown provider' error related to a provider I created for fetching template URLs. This provider is injected into a config function that is ...

Retrieve Image URL from RSS Medium Feed

I am attempting to showcase the images from each post in medium's RSS feed using only JavaScript or Angular, without relying on JQuery. I am able to retrieve the title, creation date, and link for each post. Currently, I am developing with Ionic2. en ...

Navigating with buttons in React JS

In my material-ui, I have a button set up like this: <Button style={green} raised="true" label="Continue to create group"}> CREATE NEW GROUP </Button> I am looking to make it so that when the button is clicked, it will take me ...

Position the image on the right side of several lines of text

My webpage contains two div elements: one for displaying multi-line text and the other for showing an image which is positioned to the right of the text. The width of the image is not fixed and can be adjusted using a user-defined parameter. <div> ...