Difference between ID and Class

What is the difference between ID and class? what is the appropriate use cases of each?

in the Coffee cards- lesson, instead of using #product id, we can use it as a class also?

and in the “Forms in HTML” lesson the following code is used in CSS to make the “Order” in the center position

	width: 100%;

	text-align: center;

but without using the .order-selection{width: 100%;} also the text is at center, can we use like that?

Hi @sujitth ,
IDs are used for uniquely identifying an element. 1 ID can only be assigned to 1 element.

Multiple elements can have the same class.

You can use IDs and classes in the same way, but keep the above definitions in mind.

By default, the width of the parent is inherited, so you may not set width:100% if the width of the parent is 100%, which is the case with the body element. In this case, you may do that. Remember the width of the body element is by default the same as the viewport width, but the height is not. You’ll understand all of this in the course.