SlideShare a Scribd company logo
nisa1207@gmail.com 
prog_nisa@quest.edu.pk
Adding 
Images 
Adding images to a web page 
Using the src, alt, width, and 
height attributes 
2
A web page with all text and no pictures isn’t much fun. The Web’s explosion 
into mass popularity was due in part to the fact that there were images on 
the page. Before images, the Internet was a text-only. 
Images appear on web pages in two ways: 
embedded in the 
inline content 
• Using <img> 
Background 
images 
• Using CSS 
3
First it’s important to know that you can’t put just any 
image on a web page. In order to be displayed inline, 
images must be in the GIF, JPEG, or PNG file format. 
In addition to being in an appropriate format, image files 
need to be named with the proper suffixes—.gif, .jpg (or 
.jpeg), and .png, respectively—in order to be recognized 
by the browser. 
4
<img> Adds an inline image 
The img element tells the browser, “Place an image here.” You’ve 
already gotten a preview of it used to place banner graphics. You 
can also place an image element right in the flow of the text at 
the point where you want the image to appear, as in the following 
example. Images stay in the flow of text and do not cause any line 
breaks. 
5
<p>I had been wanting to go to Tuscany 
<img src="tuscany.jpg" alt=""> 
for a long time, and I was not disappointed. 
</p> 
6
src="URL” Source (location) of the image 
The value of the src attribute is the URL of the image file. In most 
cases, the images you use on your pages will reside on your server, 
so you will use relative URLs to point to them. 
In short, if the image is in the same directory as the HTML 
document, you can just refer to the image by name in the src 
attribute: 
<img src="icon.gif" alt=“icon image"> 
<img src="/images/arrow.gif" alt=""> 
<img src="http://www.example.com/images/smile.gif" alt=""> 
7
alt="text“ Alternative text 
Every img element must also contain an alt attribute that is used to provide 
a brief description of the image for those who are not able to see it, such as 
users with screen readers, braille, or even small mobile devices. Alternate 
text (also referred to as alt text) should serve as a substitute for the image 
content—serving the same purpose and presenting the same information. 
<p>If you're <img src="happyface.gif" alt="happy"> and you know it clap 
your hands.</p> 
A screen reader might indicate the image by reading its alt value this way: 
“If you’re image happy and you knowit clap your hands.” 
8
If the image simply fails to load, the browser may 
display the alternative text to give the user an 
idea of what is missing. The handling of 
alternative text is inconsistent among modern 
browsers, however, as shown in Figure: 
9
10
width="number“ : Image width in pixels 
height="number“ : Image height in pixels 
The width and height attributes indicate the dimensions of the 
image in number of pixels. 
11
Be sure that the pixel dimensions 
you specify are the actual 
dimensions of the image. If the 
pixel values differ from the actual 
dimensions of your image, the 
browser resizes the image to 
match the specified values. 
12
you should avoid doing so. Even though the image may appear 
small on the page, the large image with its corresponding large file 
size still needs to download. It is better to resize the image in an 
image-editing program and then place it at actual size on the page. 
Not only that, but resizing with attributes usually results in a 
blurry and deformed image. In fact, if your images ever look fuzzy 
when viewed in a browser, the first thing to check is that the width 
and height values match the dimensions of the image exactly. 
13
14 
S.No Attribute Purpose 
1 Border Define the border around the image 
2 Src Defines the path of image 
3 Width Defines the width of image 
4 Height Defines the height of image 
5 Title Defines the tool tip 
6 Alt Specifies extra information about an element 
7 hspace Specifies the whitespace on left and right side of an image 
8 Vspace specifies the whitespace on top and bottom of an image 
9 Align To align image. Possible valuesTop, bottom, middle,left and right
15

More Related Content

Viewers also liked

An Introduction to HTML
An Introduction to HTMLAn Introduction to HTML
An Introduction to HTMLcrea8ivemoiz
 
Html (hyper text markup language)
Html (hyper text markup language)Html (hyper text markup language)
Html (hyper text markup language)Denni Domingo
 
HTML (Hyper Text Markup Language)
HTML (Hyper Text Markup Language)HTML (Hyper Text Markup Language)
HTML (Hyper Text Markup Language)
Jishan Ali
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
Shehzad Yaqoob
 
The History of the Internet
The History of the Internet The History of the Internet
The History of the Internet crea8ivemoiz
 
HTML Basics by software development company india
HTML Basics by software development company indiaHTML Basics by software development company india
HTML Basics by software development company india
iFour Institute - Sustainable Learning
 

Viewers also liked (8)

An Introduction to HTML
An Introduction to HTMLAn Introduction to HTML
An Introduction to HTML
 
Html (hyper text markup language)
Html (hyper text markup language)Html (hyper text markup language)
Html (hyper text markup language)
 
HTML (Hyper Text Markup Language)
HTML (Hyper Text Markup Language)HTML (Hyper Text Markup Language)
HTML (Hyper Text Markup Language)
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
Html
HtmlHtml
Html
 
Leng Kee
Leng KeeLeng Kee
Leng Kee
 
The History of the Internet
The History of the Internet The History of the Internet
The History of the Internet
 
HTML Basics by software development company india
HTML Basics by software development company indiaHTML Basics by software development company india
HTML Basics by software development company india
 

Similar to HTML Images

Html images and html backgrounds
Html images and html backgroundsHtml images and html backgrounds
Html images and html backgrounds
nobel mujuji
 
HTML5 - Insert images and Apply page backgrounds
HTML5 - Insert images and Apply page backgroundsHTML5 - Insert images and Apply page backgrounds
HTML5 - Insert images and Apply page backgrounds
Grayzon Gonzales, LPT
 
2.1 adding images
2.1 adding images2.1 adding images
2.1 adding imagesBulldogs83
 
Html images syntax
Html images syntaxHtml images syntax
Html images syntax
JayjZens
 
Html 5
Html   5Html   5
lecture4.ppt
lecture4.pptlecture4.ppt
lecture4.ppt
ssuser08ea44
 
Chapter 7: Images
Chapter 7: ImagesChapter 7: Images
Chapter 7: Images
Steve Guinan
 
Presentation
PresentationPresentation
Presentation
Bbhulme1
 
Seo for image
Seo for imageSeo for image
Seo for image
NupurSamaddar2
 
Web forms and html lecture Number 2
Web forms and html lecture Number 2Web forms and html lecture Number 2
Web forms and html lecture Number 2
Mudasir Syed
 
Better DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen WorldBetter DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen World
Joe Pairman
 
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation  Websites Session 7 by Muhammad Ehtisham SiddiquiBuilding Next Generation  Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
Image SEO: 22 Strategies for Higher Ranking Visuals
Image SEO: 22 Strategies for Higher Ranking VisualsImage SEO: 22 Strategies for Higher Ranking Visuals
Image SEO: 22 Strategies for Higher Ranking Visuals
SEO Sherpa
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
Vitaly Friedman
 
Aaug sample slides
Aaug sample slidesAaug sample slides
Aaug sample slides
Casandra Calo
 
Layouts Part 2
Layouts Part 2Layouts Part 2
Layouts Part 2
kjkleindorfer
 
Designing web page marquee and img tag
Designing web page  marquee and img tagDesigning web page  marquee and img tag
Designing web page marquee and img tag
Jesus Obenita Jr.
 
Rwd slidedeck
Rwd slidedeckRwd slidedeck
Rwd slidedeck
Vera Kovaleva
 

Similar to HTML Images (20)

Html images and html backgrounds
Html images and html backgroundsHtml images and html backgrounds
Html images and html backgrounds
 
HTML5 - Insert images and Apply page backgrounds
HTML5 - Insert images and Apply page backgroundsHTML5 - Insert images and Apply page backgrounds
HTML5 - Insert images and Apply page backgrounds
 
2.1 adding images
2.1 adding images2.1 adding images
2.1 adding images
 
Html images syntax
Html images syntaxHtml images syntax
Html images syntax
 
Html 5
Html   5Html   5
Html 5
 
lecture4.ppt
lecture4.pptlecture4.ppt
lecture4.ppt
 
Chapter 7: Images
Chapter 7: ImagesChapter 7: Images
Chapter 7: Images
 
Presentation
PresentationPresentation
Presentation
 
Seo for image
Seo for imageSeo for image
Seo for image
 
Web forms and html lecture Number 2
Web forms and html lecture Number 2Web forms and html lecture Number 2
Web forms and html lecture Number 2
 
Session no 4
Session no 4Session no 4
Session no 4
 
Better DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen WorldBetter DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen World
 
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation  Websites Session 7 by Muhammad Ehtisham SiddiquiBuilding Next Generation  Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
 
Unit 2.7 Images
Unit 2.7 ImagesUnit 2.7 Images
Unit 2.7 Images
 
Image SEO: 22 Strategies for Higher Ranking Visuals
Image SEO: 22 Strategies for Higher Ranking VisualsImage SEO: 22 Strategies for Higher Ranking Visuals
Image SEO: 22 Strategies for Higher Ranking Visuals
 
Responsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and TechniquesResponsive Web Design: Clever Tips and Techniques
Responsive Web Design: Clever Tips and Techniques
 
Aaug sample slides
Aaug sample slidesAaug sample slides
Aaug sample slides
 
Layouts Part 2
Layouts Part 2Layouts Part 2
Layouts Part 2
 
Designing web page marquee and img tag
Designing web page  marquee and img tagDesigning web page  marquee and img tag
Designing web page marquee and img tag
 
Rwd slidedeck
Rwd slidedeckRwd slidedeck
Rwd slidedeck
 

More from Nisa Soomro

PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and Sessions
Nisa Soomro
 
Form Handling using PHP
Form Handling using PHPForm Handling using PHP
Form Handling using PHP
Nisa Soomro
 
Connecting to my sql using PHP
Connecting to my sql using PHPConnecting to my sql using PHP
Connecting to my sql using PHP
Nisa Soomro
 
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
Nisa Soomro
 
PHP Filing
PHP Filing PHP Filing
PHP Filing
Nisa Soomro
 
Html5
Html5Html5
HTML Basic Tags
HTML Basic Tags HTML Basic Tags
HTML Basic Tags
Nisa Soomro
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
Nisa Soomro
 
HTML Frameset & Inline Frame
HTML Frameset & Inline FrameHTML Frameset & Inline Frame
HTML Frameset & Inline Frame
Nisa Soomro
 
HTML Lists & Llinks
HTML Lists & LlinksHTML Lists & Llinks
HTML Lists & Llinks
Nisa Soomro
 
HTML Tables
HTML TablesHTML Tables
HTML Tables
Nisa Soomro
 
Html5 Canvas Detail
Html5 Canvas DetailHtml5 Canvas Detail
Html5 Canvas DetailNisa Soomro
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
Nisa Soomro
 
Html5
Html5Html5
Web programming lec#3
Web programming lec#3Web programming lec#3
Web programming lec#3Nisa Soomro
 

More from Nisa Soomro (17)

PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and Sessions
 
Form Handling using PHP
Form Handling using PHPForm Handling using PHP
Form Handling using PHP
 
Connecting to my sql using PHP
Connecting to my sql using PHPConnecting to my sql using PHP
Connecting to my sql using PHP
 
Basic of PHP
Basic of PHPBasic of PHP
Basic of PHP
 
PHP Filing
PHP Filing PHP Filing
PHP Filing
 
Html5
Html5Html5
Html5
 
HTML Basic Tags
HTML Basic Tags HTML Basic Tags
HTML Basic Tags
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
HTML Frameset & Inline Frame
HTML Frameset & Inline FrameHTML Frameset & Inline Frame
HTML Frameset & Inline Frame
 
HTML Lists & Llinks
HTML Lists & LlinksHTML Lists & Llinks
HTML Lists & Llinks
 
HTML Tables
HTML TablesHTML Tables
HTML Tables
 
Html5 SVG
Html5 SVGHtml5 SVG
Html5 SVG
 
Html5 Canvas Detail
Html5 Canvas DetailHtml5 Canvas Detail
Html5 Canvas Detail
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
 
Html5
Html5Html5
Html5
 
Html
HtmlHtml
Html
 
Web programming lec#3
Web programming lec#3Web programming lec#3
Web programming lec#3
 

Recently uploaded

June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 

Recently uploaded (20)

June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 

HTML Images

  • 2. Adding Images Adding images to a web page Using the src, alt, width, and height attributes 2
  • 3. A web page with all text and no pictures isn’t much fun. The Web’s explosion into mass popularity was due in part to the fact that there were images on the page. Before images, the Internet was a text-only. Images appear on web pages in two ways: embedded in the inline content • Using <img> Background images • Using CSS 3
  • 4. First it’s important to know that you can’t put just any image on a web page. In order to be displayed inline, images must be in the GIF, JPEG, or PNG file format. In addition to being in an appropriate format, image files need to be named with the proper suffixes—.gif, .jpg (or .jpeg), and .png, respectively—in order to be recognized by the browser. 4
  • 5. <img> Adds an inline image The img element tells the browser, “Place an image here.” You’ve already gotten a preview of it used to place banner graphics. You can also place an image element right in the flow of the text at the point where you want the image to appear, as in the following example. Images stay in the flow of text and do not cause any line breaks. 5
  • 6. <p>I had been wanting to go to Tuscany <img src="tuscany.jpg" alt=""> for a long time, and I was not disappointed. </p> 6
  • 7. src="URL” Source (location) of the image The value of the src attribute is the URL of the image file. In most cases, the images you use on your pages will reside on your server, so you will use relative URLs to point to them. In short, if the image is in the same directory as the HTML document, you can just refer to the image by name in the src attribute: <img src="icon.gif" alt=“icon image"> <img src="/images/arrow.gif" alt=""> <img src="http://www.example.com/images/smile.gif" alt=""> 7
  • 8. alt="text“ Alternative text Every img element must also contain an alt attribute that is used to provide a brief description of the image for those who are not able to see it, such as users with screen readers, braille, or even small mobile devices. Alternate text (also referred to as alt text) should serve as a substitute for the image content—serving the same purpose and presenting the same information. <p>If you're <img src="happyface.gif" alt="happy"> and you know it clap your hands.</p> A screen reader might indicate the image by reading its alt value this way: “If you’re image happy and you knowit clap your hands.” 8
  • 9. If the image simply fails to load, the browser may display the alternative text to give the user an idea of what is missing. The handling of alternative text is inconsistent among modern browsers, however, as shown in Figure: 9
  • 10. 10
  • 11. width="number“ : Image width in pixels height="number“ : Image height in pixels The width and height attributes indicate the dimensions of the image in number of pixels. 11
  • 12. Be sure that the pixel dimensions you specify are the actual dimensions of the image. If the pixel values differ from the actual dimensions of your image, the browser resizes the image to match the specified values. 12
  • 13. you should avoid doing so. Even though the image may appear small on the page, the large image with its corresponding large file size still needs to download. It is better to resize the image in an image-editing program and then place it at actual size on the page. Not only that, but resizing with attributes usually results in a blurry and deformed image. In fact, if your images ever look fuzzy when viewed in a browser, the first thing to check is that the width and height values match the dimensions of the image exactly. 13
  • 14. 14 S.No Attribute Purpose 1 Border Define the border around the image 2 Src Defines the path of image 3 Width Defines the width of image 4 Height Defines the height of image 5 Title Defines the tool tip 6 Alt Specifies extra information about an element 7 hspace Specifies the whitespace on left and right side of an image 8 Vspace specifies the whitespace on top and bottom of an image 9 Align To align image. Possible valuesTop, bottom, middle,left and right
  • 15. 15