📄 html_images.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML Images</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>HTML Images</h1>
<a href="html_forms.asp"><img border="0" src="../images/btn_previous.gif" width="100" height="20" alt="Previous" /></a>
<a href="html_backgrounds.asp"><img border="0" src="../images/btn_next.gif" alt="Next" width="100" height="20" /></a>
<hr />
<p class="intro">With HTML you can display images in a document.</p>
<hr />
<h2>Examples</h2>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_images">Insert images</a><br />
This example demonstrates how to display images in your Web page.</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_images2">Insert images from different
locations</a><br />
This example demonstrates how to display images from another folder or another
server in your Web page.</p>
<p>(You can find more examples at the bottom of this page)</p>
<hr />
<h2>The Image Tag and the Src Attribute
</h2>
<p>In HTML, images are defined with the <img> tag.
</p>
<p>The <img> tag is empty, which means that it contains attributes
only and it has no closing tag.
</p>
<p>To display an image on a page, you need to use the src attribute. Src stands for
"source". The value of the src attribute is the URL of the image you want to
display on your page.
</p>
<p>The syntax of defining an image:</p>
<table width="100%" class="ex" cellspacing="0" border="1">
<tr>
<td>
<pre><img src="url"></pre>
</td>
</tr>
</table>
<p>
The URL points to the location where the image is stored. An image named "boat.gif" located in the directory
"images" on "www.w3schools.com" has the URL:
http://www.w3schools.com/images/boat.gif.
</p>
<p>The browser puts the image where the image tag occurs in the document. If you put an image tag between two
paragraphs, the browser shows the first paragraph, then the image, and then the second
paragraph.
</p>
<hr />
<h2>
The Alt Attribute
</h2>
<p>
The alt attribute is used to define an "alternate text" for an image. The value of
the alt attribute is an author-defined text:
</p>
<table width="100%" class="ex" cellspacing="0" border="1">
<tr>
<td>
<pre><img src="boat.gif" alt="Big Boat"></pre>
</td>
</tr>
</table>
<p>The "alt" attribute tells the reader what he or she is missing on a
page if the browser can't load images. The browser will then display the
alternate text instead of the image. It is a good practice to include the
"alt" attribute for each image on a page, to improve the display and usefulness of your document for people who
have text-only browsers.
</p>
<hr />
<h2>Basic Notes - Useful Tips</h2>
<p>If an HTML file contains ten images - eleven files are required to display the page
right. Loading images take time, so my best advice is: Use images carefully.
</p>
<hr />
<h2>More Examples</h2>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_bodybgimg">Background image</a><br />
This example demonstrates how to add a background image to an HTML page.</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_image_align">Aligning images</a><br />
This example demonstrates how to align an image within the text.</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_image_float">Let the image float</a><br />
This example demonstrates how to let an image float to the left or right of a
paragraph.</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_images_adj">Adjust images to different
sizes</a><br />
This example demonstrates how to adjust images to different sizes.</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_images_alt">Display an alternate text for an
image</a><br />
This example demonstrates how to display an alternate text for an image. The "alt" attribute tells the
reader what he or she is missing on a page if the browser can't load images. It is a
good practice to include the "alt" attribute for each image on a page.</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_imglink">Make a hyperlink of an image</a><br />
This example demonstrates how to use an image as a link.</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_areamap">Create an image map</a><br />
This example demonstrates how to create an image map, with clickable regions.
Each of the regions is a hyperlink.</p>
<p><a target="_blank" href="tryit.asp@filename=tryhtml_ismap">Turn an image into an image map</a><br />
This example demonstrates how to turn an image into an image map. You will see
that if you move the mouse over the image, the coordinates will be displayed on the status bar.
</p>
<hr />
<h2>Image Tags</h2>
<table class="ex" cellspacing="0" border="1" width="100%">
<tr>
<th align="left">Tag</th>
<th align="left">Description</th>
</tr>
<tr>
<td><a href="../tags/tag_img.asp"><img></a></td>
<td>Defines an image</td>
</tr>
<tr>
<td><a href="../tags/tag_map.asp"><map></a></td>
<td>Defines an image map</td>
</tr>
<tr>
<td><a href="../tags/tag_area.asp"><area></a></td>
<td>Defines a clickable area inside an image map</td>
</tr>
</table>
<br />
<hr />
<a href="html_forms.asp"><img border="0" src="../images/btn_previous.gif" width="100" height="20" alt="Previous" /></a>
<a href="html_backgrounds.asp"><img border="0" src="../images/btn_next.gif" width="100" height="20" alt="Next" /></a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -