Custom element in `<head>`
See original GitHub issueI came upon this today, I am developing a Static Website Generator and I want to allow for layout templates like:
<html>
<head>
<site-include type="partial" name="scripts"></site-include>
</head>
</html>
So here you see the tag site-include
denotes where a partial page should be included (in this case the scripts partial page in the head).
In my C# code I then QuerySelector
the site-include
and ReplaceWith
the partial.
But or course the problem is that when I use the HTMLParser
the above template gets turne into:
<html>
<head>
</head>
<body>
<site-include type="partial" name="scripts"></site-include>
</body>
</html>
Is there any option I can set to the HTMLParser
to allow custom elements inside the <head>
?
I believe your parser is working as is correct for browsers, but it is not what I need for my purposes.
Issue Analytics
- State:
- Created 2 years ago
- Comments:21 (9 by maintainers)
Top Results From Across the Web
Are HTML5 custom elements allowed in <HEAD>
My question is, can HTML5 custom-elements be used in HEAD? ... is moving the custom element out of the head section, into the...
Read more >Google's John Mueller Warns Against Custom Elements In ...
Custom elements in document heads can disrupt Google's rendering, potentially harming SEO; JSON-LD offers a flexible alternative.
Read more >Custom code in head and body tags
Custom code entered in the Head code section appears before the closing </head> tag in your site's HTML markup and applies to your...
Read more >Using custom elements - Web APIs | MDN
Autonomous custom elements are standalone — they don't inherit from standard HTML elements. You use these on a page by literally writing them ......
Read more >Components: <Head>
Add custom elements to the `head` of your page with the built-in Head ... We expose a built-in component for appending elements to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
3rd time lucky 😉
I guess I didn’t realise it would do this, I have used AngleSharp in the past and had the idea of using it with this project.
An option to make the parser non HTML5 conformant would be the solution… But I could look at using XML like you say, the
System.Xml.Linq
namespace has similar manipulation methods, so I will give this a try.At this stage I am just doing unit tests and experimenting to see what direction to go in.