How do I add image to my web page?

  • Thread starter Thread starter Math10
  • Start date Start date
  • Tags Tags
    Image Web
AI Thread Summary
To add an image to a web page, use the <img> element with the correct src and alt attributes, formatted as <img src="URL" alt="description">. The src should contain the path to the image file; if the image is in the same directory as the HTML file, simply use the file name. If the image is located elsewhere, provide the full URL or the relative path to the image. The alt attribute is for alternate text displayed if the image cannot be loaded, but it is not essential for the image to display. Ensure the image file is accessible online or correctly linked for proper display.
Math10
Messages
301
Reaction score
0

Homework Statement


How do I add image to my web page?

Homework Equations


None.

The Attempt at a Solution


I know that the img element is <img src="logo.png" alt="My Logo"> but I don't know what to type between the 2 quotation marks for "logo.png" and "My Logo". I put logo.png and My Logo between them but it doesn't work. What should I input between " " and " "?
 
Physics news on Phys.org
Math10 said:

Homework Statement


How do I add image to my web page?

Homework Equations


None.

The Attempt at a Solution


I know that the img element is <img src="logo.png" alt="My Logo"> but I don't know what to type between the 2 quotation marks for "logo.png" and "My Logo". I put logo.png and My Logo between them but it doesn't work. What should I input between " " and " "?
If logo.png is in the same directory as the HTML page that contains this img element, what you have should work. If the file is in some other directory, you need to supply the path and file name.

The alt attribute is alternate text to display in case the viewer's browser is unable to download the image. You can put in there pretty much whatever you want.
 
As Mark44 said, but let me elaborate.

Is your picture online right now? Are you able to see it somewhere? If so, how? You must have a URL that points to it. (the address in your address bar of your browser).

The URL is what you put in the src="". There are subtleties, but that's the gist of it.

Don't worry about alt too much just yet. It is not essential to displaying your image.
 

Similar threads

Back
Top