-Img HTML parsing element in

A, <img> HTML image
 using the <img> tag defines the image in an HTML page. <img> tag has two required attributes: src and alt.

HTML image - image tag (<img>) and a source property (the Src)

 In HTML, an image defined by the <img> tag.

 <Img> tag is empty, meaning that it contains properties, and tag is not closed.

 To display the image on the page, you need to use the source attribute (src). src refers to the "source". Value of the source attribute is the URL of the image.

 Defining an image syntax is:

  <IMG the src = "URL" Alt = "SOME_TEXT">
 the URL of the image position storage means. If the image is named "boat.gif" located www.w3cschool.cn the images directory, then the URL is //www.w3cschool.cn/images/boat.gif.

 The browser will display the image where the image tag occurs in the document. If you put an image tag between two paragraphs, the browser will first display the first paragraph, and then display the images displayed last second paragraph.


HTML image - Alt attribute
 alt attribute used to define the alternative text string image prepared. Practice using the alt attribute of the method in the test program.

 Replacement text attribute value is user defined.

  <img src = "boat.gif" alt = "Big Boat">
 in the browser can not load images, text attributes tell the reader replace their lost information. In this case, the browser will display the alternate text instead of images. The image on the page are plus replacement text property is a good habit, which helps to better display information, and is very useful for those who use text-only browsers in terms of.


HTML image - setting the height and width of the image
 height (the height of) the image height and width provided with a width (width) attribute. You can resize an image in the test program.

 The default attribute value in pixels:

<img src = "pulpit.jpg" alt = "Pulpit rock" width = "304" height = "228">
Tip: A good height and width specified image habits. It will retain the size specified if the image height is specified width, when the page loads. If you do not specify the size of the picture, it is possible when the page loads would undermine the overall layout of the HTML page.


Set the image frame
 in <img> tag, you can use the border attribute to specify the border thickness in pixels. The thickness of 0 indicates no border around the picture.

<img src="/statics/images/course/pulpit.jpg" alt="Pulpit rock" border = "3">

Image alignment is provided
 by default, the left image is displayed in a page-aligned, the <img> tag you can use the property is set to align the alignment of the image: center (middle) or right (right side).

<img src="/statics/images/course/pulpit.jpg" alt="Pulpit rock" align="right">

Basic precautions - Helpful hints:
Note: If an HTML file contains ten images, then in order to display this page correctly, you need to load the 11 files. Load picture takes time, so our advice is: caution pictures.

Note: When the page is loaded, the path should pay attention to insert page images, if you can not set the correct position of the image, the browser can not load images, image labels will display a broken picture.

Guess you like

Origin www.cnblogs.com/sqyss/p/11117114.html