Can I set ids and classes in Tyles, scripts, etc?

Asked

Viewed 34 times

1

I can set ids and classes in style, script, etc.?

Example:

<style class="teste" id="teste">
/*
  Meu codigo aqui
*/
</style>

2 answers

1

You can. Whenever you have doubt you can consult the MDN which is considered the official documentation. It contains all the attributes that each tag allows. In the case of both tags allow these attributes because they are part of the global attributes.

To the <style>.

To the <script>.

1


You can, you’ve 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.