+ 3

what is the differences between "id", "class" and "span"?

please explain the difference between" id", "class" and "span" in HTML, CSS, JS

21st Dec 2017, 5:38 AM
Sicelo Mpungose
Sicelo Mpungose - avatar
5 Respuestas
+ 10
An ID is a unique element there can only be one element with that particular ID. You can apply a class to many elements at the same time so that they will all be styled according to the class.
25th Dec 2017, 4:00 PM
Louis
+ 7
A span is an html tag. ex. <span></span> class and Id are tag attributes for css identification. Tag names like span can also be used to identify an element in css. An id has to be unique there can only be one of that element with a given id. For a class it can be placed on multiple elements to style them all in a particular way through css.
21st Dec 2017, 5:45 AM
Louis
+ 4
The differences are pretty big! for example, the <span> tag is used as a container for text, class is used to connect to the css code, and the one in its charm adds styles to your page! id, is needed in order for some languages ​​such as javascript, and php could directly contact the html code :)
21st Dec 2017, 5:47 AM
James16
James16 - avatar
+ 2
Id and class is attributes of element, span is element itself. So you can have such html <span class="yo" id="mate">Text</span> only "Text" will be displayed in browser, but you can refer to this element in your css or Js by it id or class.
21st Dec 2017, 5:43 AM
Dima Makieiev
Dima Makieiev - avatar
+ 1
If I had to choose between using "id" or "class" in my code, what would be a deciding factor? Do they play the same role?
21st Dec 2017, 7:14 AM
Sicelo Mpungose
Sicelo Mpungose - avatar