After discussion with some of my friends about css concepts, I have some questions to ask to you guys.
When do we use Id and class in css? and we have a conflict idea with Div and Span. When are Div and Span are used?
Any key to these questions?
A basic rule is that an ID may only exists once in the complete page. The ID is usually used to identify an object in your page. Most of the time you will use class in CSS.
A span is an in-line element, a div is a block element (by default, you can override this in your CSS). Spans are usually used inside a textblock to "mark" a piece of text. A div is used to group objects in a container.
Hope this helps you a bit.
div
is used as a section of a document. span
is used to style individual parts of text. A key difference is that a div will insert a line break on either side.
However div
and span
are HTML not CSS.
You use id
when there is one of an element and you need it to be uniquely identified.
You use class
when there are multiple element which you want to apply the same stylings to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With