In this page complete use and syntax of id attribute is given . The id attribute is used to assign a unique identifier to an element in the document.As we know that we can use class for many time,But in other words, the value of id must be used only once in the document. This makes it useful for assigning a name to a particular element,as though it were a piece of data. See the sidebar id and class Values for information on providing values for the id attribute.
Basic example of ID attribute
<
!DOCTYPE html
>
<
html
>
<
head
>
<
style
>
.mainArea
{
border
:
1px solid black
;
background
:
white
;
padding
:
5px
;
}
#heading5
{
font-size
:
26px
;
font-family
:
"Segoe UI",Arial,sans-serif
;
font-weight
:
400
;
color
:
blue
;
}
.para1
{
font-size
:
15px
;
color
:
black
;
padding
:
5px
;
text-align
:
justify
;
}
<
/style
>
<
/head
>
<
body
>
<
div
class
="
mainArea
"
>
<
h5
id
="
heading5
"
>
webtags.com.pk<
/h5
>
<
p
class
="
para1
"
>
webtags is free course provider website.
Here are complete web development and web designing courses for free
to learn.There is no any condition for registration or login for the user.<
/p
>
<
/div
>
<
/body
>
<
/html
>
Output of above code
webtags.com.pk
webtags is free course provider website. Here are complete web development and web designing courses for free to learn.There is no any condition for registration or login for the user.
Explanation of above code
As you saw the above example with source, here id attribute is targeted in css to make the document more attractive.(You will learn more about style in css tutorials).Here are also Two classes were used in the above document, "mainArea" and "para1" but we will discuss about id attribute. And same to class attribute here id attribute is targeted in above styling (internal type of styling). When we target the id attribute in css than we use "#" (hash) sign before the id attribute.
Note:
If you are willing to learn more about id attribute don't forget to visit CSS course.
Comment here
If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.