Which of the following attributes can be used to define the location of an image?
XHTML Images Show
This section covers adding images to your page and several methods for controlling the flow of text around images. Inserting imagesImages are inserted using the img element. The most common formats for images are GIF, JPEG, and PNG. The src attribute specifies the image's location on either the local file system or the Web, and the alt attribute specifies a text string that should be displayed if the browser cannot load the image. Programming the ENIACThis monster occupied an entire room, but was programmable. Here are some ideas to consider when using images.
Specifying image sizeThe width and height attributes control an image's dimensions. When these attributes are specified, the browser can construct the page more quickly because it can render the page and download the image in parallel. Otherwise, the browser must first download the image to determine its dimensions and then render the remainder of the page. Programming the ENIACwidth="400" height="310" />This monster occupied an entire room, but was programmable. The width and height attributes can also be used to scale an image. For example, if the image is 400×310 pixels and you want to display it half-sized, specify width="200" and height="155". A few things to note about specifying an image's width and height:
width="200" />
Images and page layoutFloating imagesThe align attribute can make an image float along one side of the page, with text and other elements wrapping around the other side. NOTE: This attribute is deprecated because style sheets are more commonly used to control image layout. The markup and sample output below demonstrate left floating. align="left" />Programming the ENIACENIAC, short for Electronic Numerical Integrator and Computer, ... ... Alternatively, specifying align="right" yields the following sample output: Different images can have different float types. The key is to place each img element directly before the text that it should disrupt. The markup and sample output below demonstrate left and right floating. align="right" />Programming the ENIACENIAC, short for Electronic Numerical Integrator and Computer, ... align="left" />The contract was signed on... Stopping elements from wrappingA floated image affects all the elements that follow it, unless a br element with the clear attribute is used. To force the text to follow the image use As an example, here's the original markup without line breaks and the corresponding sample output: Programming the ENIACENIAC, short for Electronic Numerical Integrator And Computer... The contract was signed on... The bottom-left image fills in some of the whitespace under the first paragraph. In particular, part of the bottom left picture and the first two lines of the second paragraph flow around the right picture. To prevent this, you can put a line break after the first paragraph indicating that succeeding text and/or images should follow the right picture. The red line in the resulting output below shows how the bottom of the first image is flush with the top of the second image. Programming the ENIACENIAC, short for Electronic Numerical Integrator And Computer... The contract was signed on... To have the second image, which is aligned on the left margin, display before the next paragraph, you can place a line break after that image. Programming the ENIACENIAC, short for Electronic Numerical Integrator And Computer... The contract was signed on... Adding space around imagesYou can add spacing between images and text by using the img element's vspace and hspace attributes. The values of these attributes are the number of pixels to use as spacing. NOTE: These attributes are also deprecated in favor of style sheets, which allow greater control over the spacing around images. A few things to note about vertical and horizontal spacing:
The following example puts 40 pixels of vertical space and 20 pixels horizontal space around the first image, and then puts 30 pixels of horizontal space around the second image. NOTE: The blue boxes indicate the spacing. vspace="40" hspace="20" />Programming the ENIACENIAC, short for Electronic Numerical Integrator And Computer... hspace="30" />The contract was signed on... Aligning images with textTo align inline images with text, use the align attribute of the img element. There are six alignment types:
The markup and sample output below demonstrate the use of each of the image alignment types. default absbottomdefault absmiddledefault bottom default middledefault texttopdefault top
Which attribute is used to specify the location of an image?The src attribute is required, and contains the path to the image you want to embed.
Which of the attributes are given to any image to locate the file?b src attribute is used to specify the location of an image file.
Which of the following HTML tags can be used to insert an image to a web page?In order to put a simple image on a web page, we use the element. This is a void element (meaning, it cannot have any child content and cannot have an end tag) that requires two attributes to be useful: src and alt . The src attribute contains a URL pointing to the image you want to embed in the page.
What are the main attributes of image?etc. src: source location of image width: width of an image height: height of an image alt: this attribute is important when image is not loaded it shows short text description of an image and also allows screen readers to read aloud. 1. src: consist of image's location.
|