Can a Div have an ID and a class?

LAST READ: APR 15 2024 | Q. BY: AISHO AHMAD

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 Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

LifeStyle & Fun

© 2024 GDATAMART.COM (All Rights Reserved)