Can I set ids
and classes to style
, script
, etc?
Example:
<style class="teste" id="teste">
/*
Meu codigo aqui
*/
</style>
Can I set ids
and classes to style
, script
, etc?
Example:
<style class="teste" id="teste">
/*
Meu codigo aqui
*/
</style>
Can you, have you already tested?
Example below.
document.getElementById('teste-style').innerHTML = 'p{color: #e41;}';
document.getElementById('teste-script').innerHTML = 'alert("Foo!");';
<style class="teste" id="teste-style">
/*
Meu codigo aqui
*/
</style>
<script id="teste-script"></script>
<p>Texto aqui!</p>
It can. Whenever in doubt you can consult the MDN which is considered the official documentation. There are all the attributes that each tag allows. In this case the two tags allow these attributes because they are part of global attributes .