02. Image Size width, height

To specify the image size, we specify the width and height properties. This way our page will know exactly how much space to leave for the image, resulting in a page that is very quickly loaded.

Here is an example HTML markup, with the corresponding CSS.

#sample {
  height: 250px;
}
Linux logo

When using these properties, be sure to scale properly to avoid any distorted images. To allow CSS to automatically select the width or height, simply specify just one of the properties.

Image classes

A common technique web designers can use is giving their image names a class of small, medium and large. This allows users to keep a consistent size scale so that images on a website are conformed.

Aching back from coding all day?

Acupressure Mat & Pillow

Aching back from coding all day? Try Back Problems

Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.

$$ Check price
144.87144.87Amazon 4.5 logo(1,890+ reviews)

More Back Problems resources

Build modern and responsive webpages

The Modern Web

Build modern and responsive webpages Try Front-end

The Modern Web will guide you through the most important tools of device-agnostic web development, including HTML5, CSS3, and JavaScript. The plain-english explanations and practical examples emphasize the techniques, principles, and practices that you'll need to easily transcend individual browser quirks and stay relevant as these technologies are updated.

$ Check price
34.9534.95Amazon 4.5 logo(30+ reviews)

More Front-end resources

Ad