Search code examples
textcenter

Text following the center of a page


i'm trying to make a simple header (HTML) with some text ( one word ). I would like the text to follow the center of the page, i mean that when i shrink the page width with the mouse i want the text change its position to the new center of the page. Please help, thanks


Solution

  • Below is the sample code. The important thing is the CSS "text-align". Does this help?

    <!DOCTYPE html>
    
    <head>
       <meta charset="utf-8">
       <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
       <title></title>
       <meta name="description" content="">
       <meta name="viewport" content="width=device-width">
    </head>
    <body>
    
        <style type="text/css">
           p.centerPara{text-align: center}
        </style>
    
        <p class="centerPara">Hello world!</p>
    </body>
    
    </html>