Tutorials

KodeKite Tools

HTML
Flexbox
SVG
Canvas
HTML Tutorial

More


HTML Id Attribute
Id Attribute

Id attribute indicate the ID of element, it should be unique in whole content, different elements should have different ids. Id attribute is used along with style attribute and all properties are listed in body of id in curly brackets {}, it is denoted by putting hash # symbol before id name.

Syntax

#idName{
property:value;
property:value;
property:value;
}


You can create any number of ids but with different names


Note:

You can give any name to id but do not forget to put hash symbol # before id name;


Example

I am paragraph with id "#p"


Don't forget that id should be unique for every element.


Practice Task

Open notepad or any other text editor, follow the following points.


  • Create any HTML element
  • Give it an id with name myid
  • Inside id put color property with orange value
  • also put font size property with value 20px

save file with name task.html or task.htm and then open it using any browser and see results.


Solution

I have id named #myid


You can give id to any element.