0

What is id?

in css or html

8th Feb 2017, 10:58 PM
Edem
Edem - avatar
3 Answers
+ 1
An "id" is an attribute to an HTML element that is used to specifically identify that element within the DOM. You access it in CSS by prefixing the name of the id with a '#'. Example: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Page Title</title> <style> #myidname { color: blue; } </style> </head> <body> <div id="myidname"> <h1>Hello</h1> <p>Hope this helps!</p> </div> </body> </html> Here the CSS in the style tags within the head tags gets the div element with the id of "myidname" and applies the style color:blue; to it and its child elements inherit the color blue from it making the text in the h1 and the p tags blue.
8th Feb 2017, 11:11 PM
ChaoticDawg
ChaoticDawg - avatar
0
id's are called attributes, they provide additional information about a particular tag. e.g the code below we have an id of "example". <p id="example"> Hello World! </p> id's can be used to target elements and modify those elements with CSS. id's can also be used to link to different sections of the same document( fragment identifiers). there are more things which you can do with id's but yeah there's a few of the options you have with id's.
8th Feb 2017, 11:11 PM
Ousmane Diaw
0
Thank you very much guys, really grateful.
8th Feb 2017, 11:23 PM
Edem
Edem - avatar