Tutorials

KodeKite Tools

HTML
Flexbox
SVG
Canvas
HTML Tutorial

More


HTML Image
Images

Image is used to insert image in html document, following attributes are used with image element.


  • src
  • alt
  • width
  • height
Src Attribute

Src attribute is used to insert image in HTML document, src stands for source and source is image location.

Syntax

<img src=image location />


You can use image element any where within a HTML document.


Example

image
Alt Attribute

alt attribute is used to provide information about image <img /> tag. The alt full form is alternate, By using alt attribute you can show message about image to viewer when your image does not appear in browser.

Syntax

<img src=image location alt=about image />


Example

angry bird
Width & Height Attributes

Width and Height attributes of image increses or decreases size of image.

Syntax

<img src=image location alt=about image width=width in %, number height=height in %, number />


Example

background
Image Shapes

You can make any shape of image using CSS.

Shape 1

Example

Image
Shape 2

Example

Image
Shape 3

Example

Image
Shape 4

Example

Image Image
Shape 5

Example

Image

Image is not a pair tag and output of image is image like you can see in above example.


Practice Task

Open notepad or any other text editor, follow the following points.


  • Insert image using <img /> element
  • Set width and height of 200 200 respectively
  • Think about a shape and apply to image as per your wish

save file with name task.html or task.htm and then open it using any browser and see results.


Solution

Image

Don't forget img is empty element which means it always comes in single not in pair.