w3resource
HTML exercises

CSS Properties: How to set the text alignment for elements

Go to Exercise page

Solution:

HTML Code:

<!DOCTYPE html>
  <html>
  <head>
  <title>How to set the text alignment for elements</title>
  <style type="text/css">
 h1 {
    text-align: center;
}

h2 {
    text-align: left;
}

h3 {
    text-align: right;
} 
  </style>
  </head>
  <body>
  <p><strong>w3resource Tutorial</strong></p>
  <h1>w3resource web development tutorial</h1>

<h2>w3resource web development tutorial</h2>

<h3>w3resource web development tutorial</h3>

  </body>
  </html>

Live Demo :

See the Pen text-align-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