Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Elm provide HTML document head tags?

Tags:

html

dom

elm

Elm does not appear to support HTML document's head node, <head>..</head>.

The question is why not support the complete HTML document with suitable functions. It would seem such an inclusion would allow expedient use of external resources such as style sheets.

Apart from DOCTYPE, HTML tags are uniformly, tagName attrList elmList. Perhaps a set of appendAttr and appendElm functions could be concocted to allow flexibility for specifying a more comprehensive VirtualDom.

Am I missing something?

like image 515
George Avatar asked Dec 07 '22 18:12

George


1 Answers

By the time that your Elm code has loaded and starts running, the browser has already read in the <head> of the HTML page that contains the Elm code, so it's too late to influence the contents of the <head>.

Elm can be embedded into an element in the page, or run full-screen (which appears to add a child to the <body>). Elm can only manipulate content within its container, not outside of it. In particular, all elements that Elm generates will be contained within the <body> of the document, whereas <head> is a sibling of <body>.

It's possible to generate HTML elements with any name you like, using Html.node "elementName". So it's possible to create a <head> element in Elm. However, a <head> element created this way would end up inside <body>, and I would expect browsers to ignore it.

like image 200
Luke Woodward Avatar answered Dec 22 '22 20:12

Luke Woodward