Home
CSS
CSS Height/Width
Tryit: Height and width properties
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <style> img.one { height: auto; } img.two { height: 200px; width: 200px; } div.three { height: 300px; width: 300px; background-color: powderblue; } </style> </head> <body> <h2>Set the height and width of elements</h2> <p>Original image:</p> <img class="one" src="ocean.jpg" width="300" height="300"><br> <p>Sized image (200x200 pixels):</p> <img class="two" src="ocean.jpg" width="300" height="300"><br> <p>The height and width of this div element is 300px:</p> <div class="three"></div> </body> </html>