Center H1

I need to center the green heading <h1> on line 12, but I am having trouble including both styles.  Please advise if possible.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    "http://www.w3.org/TR/xhtml11/DTD/xhtml11-transitional.dtd">
   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Lab 3-1b</title>
</head>
<body>
<div><h1 style="color:green">BEAUTIFUL BACKYARDS</h1></div>
Beutiful Backyards is a new company in town, and we are eager to get your business.  Please take some time to review our simple backyards.
</body>
</html>

Open in new window

rtod2Asked:
Who is Participating?
 
quizwedgeConnect With a Mentor Commented:
You could also get rid of the div and just do the following:


<h1 style="color:green; text-align:center;">BEAUTIFUL BACKYARDS</h1>
0
 
twohawksCommented:
In your div container place
style="margin-right: auto; margin-left: auto; text-align: center;"

This is not necessarily the answsser, but it could be where you bgin.
I strongly advise you do a little searching on the following text
  centering a div

I hope this helps.
0
 
twohawksCommented:
I will note a couple things for you..
while its deprecated, you will still see in transitional (and even strict) markup the old
align="center" used in a div, typically for rearward compatibility with older browsers, but also sometimes to help overcome centering challenges none-the-less.  I am not saying its recommended, only that you will still see it 'out there'.

One of the contemporary methods is to us the margin left/right auto setting, however, the result will depend on several other things falling into place...
 - is the div occupying the full width of the page section its in
 - is it doing so, or not, in conjunction with, or not, cascading 'width' settings for its parent container ?

How a container width style responds is connected to its relationship with its parent.
I only mean to point it out ...so that you can be mindful to be looking for discussions on this sort of thing as you hunting out learning materials for gaining a proper over-view, which I think is beyond the scope here.

Again, I hope this helps (a little more ;^).
0
 
rtod2Author Commented:
Perfect!  Thank You.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.