+ 2

what is the difference b/w id and class

20th Sep 2016, 11:28 AM
Ishtiaq Hussain
Ishtiaq Hussain - avatar
9 odpowiedzi
+ 9
Like others have said, classes be applied to different html elements. In addition you can also use more than one class in a single html element. One class used in multiple html elements: <div class="centered"></div> <p class="centered"></p> Multiple classes used in one html element: <div class="centered main "></div> For id, it is unique to an element. The main advantage to this is that it can uniquely be identified and called when using javascript. Browsers can also jump to parts of an html page that have id's. The selector for classes in css begin with a period "." For id, it is a "#". An easy way to remember is to think of an id number, so id goes with # <div id="sidebar"></div> .centered { /*your style*/ } .main { /*your style*/ } #sidebar { /*your style*/ }
22nd Sep 2016, 8:36 AM
Thomas Collins
Thomas Collins - avatar
+ 6
A class can be applied to multiple elements, and an ID can be used just in one element.
21st Sep 2016, 11:56 AM
William Martinez
William Martinez - avatar
+ 3
Classes are displayed in CSS using a dot on the start. Example: .myclass IDs use a #: #mybox Classes are used to set functions to any user input or action, languages like JavaScript and PhP can get data from any element using it's class. The same can happen with IDs
20th Sep 2016, 5:54 PM
Scotti
Scotti - avatar
+ 1
id Applied To Any Specific Element And Class Can Be Applied To Any Element.
12th Oct 2016, 7:44 PM
PIYUSH KUMAR
0
And alzó you can create a tag clases, i mean, style all html tags un tour documentos , example: H1 H2 { Color: #000000; Text-decoration:none; ....... } That means, that all H1 and H2 hace the same style
24th Sep 2016, 10:43 PM
Miguel Vargas González
Miguel Vargas González - avatar
0
class is the set of elements and properties,methods which are incorporated in html page.id is used as the reference to particular object or element in html page.class element is called by(#).id element is called by(.).
13th Oct 2016, 1:41 AM
sreekar
0
The major difference is that IDs can only be applied once per page, while classes can be used as many times on a page as needed.
6th Feb 2017, 6:23 AM
Devon Mwachilenga
Devon Mwachilenga - avatar
0
ID can be use only one time in a page.. Class can be use many times in a page..
21st Aug 2018, 1:08 PM
Bazil Farooqui
Bazil Farooqui - avatar
0
id can be applied once per page while a class can be used multiple times on a page. # is use to represent IDs e.g #home, #about etc. while . is used to represent a class e.g div.text { }
26th Aug 2018, 9:19 PM
Quawiyah