Why wont the text center

<div class= 'text-center'>
<h1> Walt Disney </h1>
<h5> "The way to get started is to quit talking and begin doing."</h5>
<img src ="https://www-tc.pbs.org/wgbh/americanexperience/media/__sized__/canonical_images/feature/disney_gallery_walt_13-crop-c0-54__0-4-700x394-resize-400x0-70.jpg"
onmouseover= "this.src= 'https://i.ytimg.com/vi/jMVwRZGH58I/maxresdefault.jpg'"
onmouseout="this.src= 'https://www-tc.pbs.org/wgbh/americanexperience/media/__sized__/canonical_images/feature/disney_gallery_walt_13-crop-c0-54__0-4-700x394-resize-400x0-70.jpg'"

     <p> Walt Disney was an American motion-picture and television producer and showman, famous as a pioneer of cartoons and animated films. Disney was also the creator of Walt Disney Animation Studios, Disneyland and Walt Disney World.</p>
<p> Who Was Walt Disney?

Walter Elias "Walt" Disney was born on December 5, 1901, in Hermosa, Illinois. He and his brother Roy co-founded Walt Disney Productions, which became one of the best-known motion-picture production companies in the world. Disney was an innovative animator and created the cartoon character Mickey Mouse. He won 22 Academy Awards during his lifetime, and was the founder of theme parks Disneyland and Walt Disney World.</p>
<p> for more info <a href= "https://en.wikipedia.org/wiki/Walt_Disney" >click here.
1 Like

Did you apply any styling to whatever you want to center?

i did <div align=center instead thank you

You got it? Or…? Like I am confused you didn’t detail your problem.

yes it works now ty it aligned how i wanted

1 Like

It is the best practice to use " " instead of ’ '. I mean <div class= "text-center"> instead of <div class= 'text-center'>

In CSS, there are many ways to centre an element. I preferred using margin!

BTW, the one you used is mostly used for the single element. But now, you are to centre a division (div).

I love to use margin for that.

You can put this in the CSS;

.text-center {
               margin: 0 auto;
               width: 80%;

The margin means ‘0’ px for top and bottom, then ‘auto’ means the right and left should be the same size. You need to add width before it can work!

Happy coding!

1 Like