Sometimes I see question mark tags in html, like this.
<? /* JavaScript code goes here*/ ?>
The browser turns these question mark tags into html comments, like this.
// javascript
console.log(document.querySelector("div").innerHTML);
<!--html-->
<div>
<? console.log("this is javascript") ?>
</div>
Editors like vscode even syntax highlight the code inside these <?
tags. But let's say I have code inside these tags like this.
x.map(function(item){return + item + '<li></li>'}).join('')
This is how it renders:
// javascript
console.log(document.querySelector("div").innerHTML);
<!--html-->
<div>
<?
x.map(function(item) {
return + item + '<li></li>'
}).join("");
?>
</div>
So how do these question mark tags work? Is it even valid HTML?