Why does deleting <style> tags make changes work?

Hello I’m trying to turn my h1 tag blue but for some reason it isn’t working.

Any ideas why?

EDIT: Aaand of course I figured it out by deleting the style tags but I’m still not sure why that worked.

Good question.

Style tags are for styling inside HTML, when you include it as a CSS file, no style tags are needed.

Codepen is including a line like this for you <link href="style.css" rel="stylesheet"/>

2 Likes

it worked because you don’t need to use style tag in CSS section of codepen think of it like the whole CSS section itself is one style tag everthing you write in it is considered css code writing <style> inside it is like writing style tag inside another style tag which is invalid syntax thus it did not work. As <style> is an HTML tag it cannot be used inside CSS.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.