Closed TheDutchCoder closed 6 months ago
This is a contentious point on the web where some versions of the spec allowed it and other didn't. Funnily enough, the latest version of the W3C spec allowed this. However, regardless of what the spec says, a loooooooot of websites, including massively popular ones do it. Most likely that at this point the spec should allow it, but oh well.
I think we could maybe fix this particular one in Astro, but I generally would not worry about this.
I understand the reasoning. I don't think the W3C spec allows it, unless it contains a scoped
attribute.
Regardless, it's a good practice to hoist it to the head instead so it's discoverable before the content part of the DOM parses.
Not saying it's a huge issue btw 😉
Passing the w3c markup validator is not a goal of this project. Having <style>
tags inside the body is supported by every web browser and has been for a very long time. In general the validator gives outdated advice and I'd suggest not using it. You'll find that most big websites fail its validation, despite working just fine in actual browsers. Closing because we won't change this behavior and do it for a reason (to prevent adding styles unless they are necessary).
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Hi there!
When you use an Astro island, it will inject a
<style>
tag in the body, which is not considered valid HTML. It should appear in the head directly.results from the repro:
What's the expected result?
The
<style>
tag to appear in the head instead.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-qvmcwt
Participation