How to insert image from folder
Inserting an image from a folder into an HTML document is a common task in web development. Properly organizing and referencing images can help maintain a clean and efficient project structure.
Using Relative Path
A relative path specifies the location of the image file in relation to the current HTML file. This method is useful for maintaining a consistent folder structure.
You can insert the image into your HTML file using a relative path.
- The
src
attribute in the<img>
tag specifies the path to the image file. - The path
images/example.jpg
indicates that the image is located in theimages
folder, which is at the same level as the HTML file. - The
alt
attribute provides alternative text for the image, improving accessibility and SEO.
<img src="images/example.jpg" alt="Example Image">