backgroundbackgound

Language Version: Russian Version Englis Version
Login: Password:
Remember Me
Support: ICQ: 445375683, 265445641 Phone: 1 802 659-4224

library / Web Hosting Articles / HTML articles

  1. library page Forms
  2. library page Getting Started
  3. library page Headings
  4. library page Images
  5. library page Links
  6. library page Lists
  7. library page Page Titles
  8. library page Paragraphs
  9. library page Tables
  10. library page Tags, Attributes, and Elements

Images

The img tag is used to put an image in an HTML document and it looks like this:

 <img src="http://www.htmldog.com/images/logo.gif" width="157" height="70" alt="HTML Dog logo" />

The src attribute tells the browser where to find the image. Like the a tag, this can be absolute, as the above example demonstrates, but is usually relative. For example, if you create your own image and save it as "alienpie.jpg" in a directory called "images" then the code would be <img src="images/alienpie.jpg"...

The width and height attributes are necessary because if they are excluded, the browser will tend to calculate the size as the image loads, instead of when the page loads, which means that the layout of the document may jump around while the page is loading.

The alt attribute is the alternative description. This is used for people who cannot or choose not to view images. This is a requirement in the latest versions of HTML.

Note that, like the br tag, because the img tag does not have a closing tag, it closes itself, ending with "/>"

The construction of images for the web is a little outside of the remit of this website, but it is worth noting a few things...

The most commonly used file formats used for images are GIFs and JPEGs. They are both compressed formats, and have very different uses.

GIFs can have no more than 256 colours, but they maintain the colours of the original image. The lower the number of colours you have in the image, the lower the file size will be.

GIFS SHOULD BE USED FOR IMAGES WITH SOLID COLOURS.

JPEGs on the other hand use a mathematical algorithm to compress the image and will distort the original slightly. The lower the compression, the higher the file size, but the clearer the image.

JPEGS SHOULD BE USED FOR IMAGES SUCH AS PHOTOGRAPHS.

Images are perhaps the largest files a new web designer will be handling. It is a common mistake to be oblivious to the file size of images, which can be extremely large. Web pages should download as quickly as possible, and if you keep in mind that most people still use modems that download at less than 7Kb a second (realistically it is less than 5Kb), you can see how a large file will greatly slow down the download time of a full page.

You need to strike a balance between image quality and image size. Most modern image manipulation programs allow you to compress images and the best way to figure out what is best suited for yourself is trial and error.



Lists

Unordered lists and ordered lists work the same way, except that the former is used for non-sequential lists with list items usually preceded by bullets and the latter is for sequential lists, which are normally represented by incremental numbers.

The ul tag is used to define unordered lists and the ol tag is used to define ordered lists. Inside the lists, the li tag is used to define each list item.

Change your code to the following:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>My first web page</title> </head> <body> <h1>My first web page</h1> <h2>What this is</h2> <p>A simple page put together using HTML</p> <h2>Why this is</h2> <ul> <li>To learn HTML</li> <li>To show off</li> <li>Because I've fallen in love with my computer and want to give her some HTML loving.</li> </ul> </body> </html> 

If you look at this in your browser, you will see a bulleted list. Simply change the ul tags to ol and you will see that the list will become numbered.

Lists can also be included in lists to form a structured hierarchy of items.

Replace the above list code with the following:

 <ul> <li>To learn HTML</li> <li> To show off <ol> <li>To my boss</li> <li>To my friends</li> <li>To my cat</li> <li>To the little talking duck in my brain</li> </ol> </li> <li>Because I've fallen in love with my computer and want to give her some HTML loving.</li> </ul> 

Et voil?. A list within a list. And you could put another list within that. And another within that. And so on and so forth.