CSS Styling (h1 and h2 within div not working)

Hi all,

i just started learning programming and the web project for a Tribute Page . It is at the top of the page where i have h1 and h2 within a div element. On the css styling, it wont work on both h1 and h2. What is the reason behind this.

From the image, only h2 is center and styled and nothing is applied to h1.
Any help would be much appreciated!

Hi, try adding “text-align: center” to your <h1> element style.

Hi
Thank you for the quick reply, and it worked as shown. Is there some kind of Syntax error in the way i coded?

See fork: https://codepen.io/tinapino/pen/VwaNjeZ?editors=1100
Actually, if you just remove the tag from the top of your css and remove the closing tag from the bottom, your h1 and h2 classes style just fine. You can remove inline styling you just added to center h1. Codepen automatically has the tag included, when you type it in, it seems to throw things off.

  1. List item

sorry, I formatted my reply wrong - but the <style> tag at the top and closing </style> at bottom of your css is what you need to remove. Codepen already has it added automatically.

I second this. That’s the first thing I saw when opening the post just now. That’s an html tag that’s not where it is supposed to be. It wouldn’t be needed in the html either.

1 Like

Thank you for your help!

1 Like

You are very welcome!