Why is There Invalid CSS in Mozilla’s Tutorials?

0
12
Asked By CuriousCoder92 On

I'm diving into HTML and CSS layouts and came across an example in Mozilla's tutorial about positioning. In the section about positioning, there's a sample where the first line of CSS is just `position: relative` with no selector. I showed this to AI tools like Gemini and ChatGPT, and they pointed out it's actually invalid syntax that should have no effect on the layout. But it does alter the layout in the Mozilla playground and also messes things up when I try it on my own page. I'm really confused about why this line is included in their playground.

5 Answers

Answered By CSSContext On

Actually, that paragraph does suggest updating the previous code to use `position: relative`. It’s just building on what was discussed before!

Answered By LayoutLover21 On

I think the reason it's in the Mozilla playground is that mistakes happen. It’s written by people, after all! If it really seems off, you might want to file a bug on GitHub—MDN team usually responds pretty quickly.

FixItFrank89 -

I've reported issues like that before; they really do tend to be on it! It's worth a shot.

Answered By CodeSnippetsGuru On

That example is probably not meant to be used standalone; it’s a snippet pulled from a larger example that includes selectors. So it’s likely assuming you have the full context from the prior code.

TestingTina -

But when I open the playground in a different tab to fiddle with it, it shows that line right at the top! Doesn’t that suggest it should work on its own?

Answered By MessedUpLayouts On

Could it be that the `position: relative` line is just a comment that's not appearing right? The selector below has `position: relative` again, so it might be a misunderstanding in formatting.

ConfusedChris -

Exactly! It seems like the example was trying to illustrate the `position: relative` in the body section. I was worried I was missing something that more experienced folks get!

Answered By DebuggingDanny On

It's a work in progress! Tutorials can sometimes have those little hiccups. Just keep experimenting, and you'll get the hang of it.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.