+ 1

In html or css style sheet, What is the difference between id and class ?

11th Sep 2018, 1:33 AM
Mohammad Shaan
Mohammad Shaan - avatar
3 Respuestas
+ 4
id - unique name of element class - can be used by a group of element. Reusable. ID symbol - # Class symbol - . Example: #demo - selects only one element with a "demo" id. .demo - selects elements with the same class "demo".
11th Sep 2018, 1:45 AM
Email Not Activated
+ 2
The id selector uses the id attribute of an HTML element to select a specific element. The id of an element should be unique within a page, so the id selector is used to select one unique element! To select an element with a specific id, write a hash (#) character, followed by the id of the element. The style rule below will be applied to the HTML element with id="para1": #para1 { text-align: center; color: red; } The class selector selects elements with a specific class attribute. To select elements with a specific class, write a period (.) character, followed by the name of the class. In the example below, all HTML elements with class="center" will be red and center-aligned: .center { text-align: center; color: red; } https://www.w3schools.com/css/css_syntax.asp
11th Sep 2018, 1:39 AM
sumaia akhand
sumaia akhand - avatar
0
thank you both of you
13th Sep 2018, 2:01 PM
Mohammad Shaan
Mohammad Shaan - avatar