Set heading text align to center in HTML and CSS

Description

The following code shows how to set heading text align to center.

Example


<html>
<head>
<style type="text/css">
h4 {<!-- w  w  w  .  ja va  2  s  .c o  m-->
margin: 0;
padding: 0;
font-size: 1.25em;
font-weight: bold;
text-align: center;
}

</style>
</head>

<h2>Cross<span>i</span>ng <span>Over</span></h2>
<h4>Gordon (<span>I</span>-Utah) GOP; <br />changes
part<span>i</span>es to be <span>I</span>ndependent</h4>

</body>
</html>

Click to view the demo

The code above generates the following result.

Set heading text align to center in HTML and CSS
Home »
  HTML CSS Tutorial »
    Text »
      Heading
HTML CSS Tutorial Heading
Create page heading from h1 to h6 in HTML a...
Set border-top for header in HTML and CSS
Set heading text align to center in HTML an...
Use Headings to Structure Text in HTML and ...
Use nested border to mark headings in HTML ...