w3resource
HTML exercises

CSS Properties: How to set vertical align property of an element

Go to Exercise page

Solution:

HTML Code :

 <!DOCTYPE html>
  <html>
  <head>
  <title>How to set vertical align property of an element</title>
  <style type="text/css">
img.top {
    vertical-align: text-top;
}

img.middle {
    vertical-align: middle;
}
img.bottom {
    vertical-align: text-bottom;
}

  </style>
  </head>
  <body>
  <h1><strong>w3resource Tutorial</strong></h1>

<p>An image<img src="//www.w3resource.com/images/w3resource-logo.png" alt="w3resource logo" width="100" height="50" /> with default alignment : w3resource web development tutorial</p> 

<p>An image<img class="top" src="//www.w3resource.com/images/w3resource-logo.png" alt="w3resource logo" width="100" height="50" />   with text-top alignment : w3resource web development tutorial</p> 

<p>An image<img class="middle" src="//www.w3resource.com/images/w3resource-logo.png" alt="w3resource logo" width="100" height="50" /> with text-middle alignment : w3resource web development tutorial</p>

<p>An image<img class="bottom" src="//www.w3resource.com/images/w3resource-logo.png" alt="w3resource logo" width="100" height="50" /> with text-bottom alignment : w3resource web development tutorial</p>

  </body>
  </html>

Live Demo :

See the Pen vertical-align-property-answer by w3resource (@w3resource) on CodePen.


See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
YesYesYesYesYes

Go to Exercise page

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming