0

id and class

Are the use of id and class attributes in tags purposely for styling in CSS or do they have other uses?

3rd Feb 2017, 11:44 PM
Daniel Makonor
Daniel Makonor - avatar
1 Antwort
+ 2
They most certainly do. While they are the core of CSS - CSS3 programming, they are a large part of JavaScript as well. For example, say you have a cipher software that reverses a phrase. Without IDs, you would have to use pure prompt()'s! <body> <input type="text" id="normalText"> <script> var text= document.getElementById("normalText").innerHTML; switch(text){ case "a": //some code; break;} </script> </body> If you didn't have the ID, you couldn't change the text! See?
4th Feb 2017, 12:12 AM
Jayden Webb