HTML images are elements that are used to embed images in a web page.
The HTML <img> tag is used to embed images in an HTML document.
The src attribute of the <img> tag is used to specify the URL of the image file to be displayed.
The alt attribute is used to provide alternative text for the image,
which is displayed if the image cannot be loaded.
Examples of HTML images:
<img src="image.jpg" alt="image">
<img src="image.png" alt="image">
<img src="image.gif" alt="image">
You can also set the width, height, and other properties of the image using additional attributes.
An example of using the width and height attributes in an HTML <img> tag:
<img src="image.jpg" alt="image" width="300" height="200">
This example specifies that the width of the image should be 300 pixels and the height should be 200 pixels.
The image will be displayed at these dimensions, regardless of its actual size.
It's important to note that it is not recommended to use fixed values for the width and height of an image, because it can affect the responsiveness of a website.
Instead, consider using CSS to control the size of images or use the max-width and max-height properties.
<style>
img {
max-width:100%;
max-height:100%;
}
</style>
This will ensure that images will scale down if the screen size is smaller than the image size.
To add an image as a link in HTML,
you can use the <a> (anchor) tag and nest an <img> tag inside it.
The href attribute of the <a> tag is used to specify the URL of the link, and the <img> tag is used to embed the image. Here's an example:
<a href="https://www.example.com">
<img src="image.jpg" alt="image">
</a>
In this example, the image.jpg is linked to the 'https://www.example.com' website.
When a user clicks on the image, they will be taken to that website. You can also add title and target attributes to the tag.
<a href="https://www.example.com" title="Go to example" target="_blank">
<img src="image.jpg" alt="image">
</a>
This will allow the link to open in a new tab when clicked.
It's important to note that you should always provide an alt attribute to the <img> tag
to provide an alternative description of the image.
This is especially important for accessibility, as it will allow users who are unable to see the image to understand its context.
There are many free resources available online where you can find images that you can use on your website or in your projects.
Some popular free image resources include:
Unsplash: A collection of high-resolution, royalty-free images that can be used for personal or commercial projects.
Pexels: A large collection of free stock photos that can be used for personal or commercial projects.
Pixabay: A collection of over 1.9 million public domain images and videos that can be used for personal or commercial projects.
StockSnap: A collection of high-resolution, royalty-free images that can be used for personal or commercial projects.
Gratisography: A collection of unique, high-resolution images that can be used for personal or commercial projects.
Burst by Shopify: A collection of free stock photos that are great for commercial use.
Canva: A graphic design website that provides free images and templates that you can use to create designs.
Public Domain Archive: A collection of high-quality public domain images that can be used for personal or commercial projects.
It's also worth noting that there are several other websites that provide free images, such as Flickr, Picjumbo, and others, and you can also find images on social media platforms like Instagram and Pinterest.
No comments:
Post a Comment