TOP CATEGORIES

×

Can a Div have an ID and a class?

T

Tina Shivam

Can a <div> have ID & CLASS Attribute?

Yes, In HTML we can use ID and Class both attributes together in a <div> for the uses of CSS properties.

1. Using a Class

.demo {

padding:10px;

height: 200px;

width: 400px;

}

For Example

<div class="demo">

    <p>This is the first paragraph.</p>

</div>

2. Using an ID

#demo_ID {

top-margin:40px;

}

For Example

<div id="demo_ID">

    <p>This is the first paragraph.</p>

</div>

1 votes

Your Answer

Email: advertise@gdatamart.com

Donate: To Support US

© 2024 GDATAMART.COM (All Rights Reserved)