Curriculum
Course: HTML Basic
Login

Curriculum

HTML Basic

HTML Introduction

0/1

HTML Editors

0/1

HTML Attributes

0/1

HTML Paragraphs

0/1

HTML Formatting

0/1

HTML Comments

0/1

HTML Favicon

0/1

HTML Page Title

0/1

HTML Iframes

0/1

HTML Java Script

0/1

HTML File Paths

0/1

HTML Symbols

0/1
Text lesson

Width and Height

The ‘style‘ attribute can be employed to define the dimensions of an image, including its width and height.

Example

<img src=”image.jpg” alt=”your image” style=”width:500px;height:600px;”>

 

Click to Learn

Width and Height, or Style?

The widthheight, and style attributes are all valid in HTML.

However, we recommend using the style attribute as it prevents stylesheets from altering the size of images.

Example

<!DOCTYPE html>
<html>
<head>
<style>
img {
  width: 100%;
}
</style>
</head>
<body>

<img src=”image.gif” alt=”Image Icon” width=”128″ height=”128″>

<img src=”image.gif” alt=”Image Icon” style=”width:128px;height:128px;”>

</body>
</html>