Horje
How to create HTML Image Width and Height with CSS Style

The width, height, and style attributes are all valid in HTML.


Example of Image Width and Height CSS

Here following css will change <img Width and Height
<style>
/* This style sets the width of all images to 100%: */
img {
  width: 50px;
  height: 50px;
}
</style>

Example of HTML Image

It will change of Image working with above step - 1
<img src="https://itupto.com/avatar.png" alt="HTML5 Icon">

Full Example of HTML Image Width and Height with CSS Style

The first image uses the width attribute (set to 50 pixels), but the style in the head section overrides it, and sets the width to 50px.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
<style>
/* This style sets the width of all images to 100%: */
img {
  width: 50px;
  height: 50px;
}
</style>
</head>
<body>

<h2>Width/Height Attributes or Style?</h2>

<p>The first image uses the width attribute (set to 128 pixels), but the style in the head section overrides it, and sets the width to 100%.</p>

<img src="https://itupto.com/avatar.png" alt="HTML5 Icon">

</body>
</html>

Output should be:

Full Example of HTML Image Width and Height with CSS Style





Category:
Web Tutorial
Sub Category:
HTML Images
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference