Horje

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




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