Wednesday 4 December 2013

HTML » Images

HTML Images

In this tutorial You will learn how to add images to Your page with HTML.

SYNTAX

<img src="URL or image location" />


» Adding image

There's two ways to add image. The first is from folder from Your PC or server by typing the location of the file. See example:


» EXAMPLE:


<html>
<body>

<img src="images/star.jpg" />

</body>
</html>

» Result:



















The second one is two add image from another website. See example:

» EXAMPLE:


<html>
<body>


</body>
</html>

» Result:















» Defining width and height

You can resize Your image by defining width and height.
This attributes can be use for both types: Adding from url and from PC.
You can type value for width and height how You want - with and without px at the end.

» EXAMPLE:


<html>
<body>

<img src="http://www.ausairpower.net/XIMG/Sov-Star-1.gif" height="20" width="20px" />
<img src="http://www.ausairpower.net/XIMG/Sov-Star-1.gif" height="60px" width="200" />
<img src="http://www.ausairpower.net/XIMG/Sov-Star-1.gif" height="150" width="101" />

</body>
</html>

» Result:






» Using alt attribute.

The required alt attribute specifies an alternate text for an image, if the image cannot be displayed.
alt can be only text.


» EXAMPLE:



<html>
<body>

<img src="" width="200" height="60" alt="Cannot find image."/>

</body>
</html>


» Result:


Cannot find image.

No comments:

Post a Comment