DEV Community

Joel Diharce
Joel Diharce

Posted on

Divs and Spans... O_o;

At first, while learning about this I thought "This has a use, but I just don't know it yet!" Then, BAM!! I was shown exactly how useful this is!

Div tags (<div></div) surround the elements you'd like to group together. The elements can be separate or in the same line, it doesn't really matter as long as they're surrounded by the div tags. An effect of the divs is that the elements within it are grouped into a "block level box", which would make the div, and all the elements it contains, act kind of like how the <p> tags containing text: The contents of the dive tags will get their own line.

Span tags (<span></span>) are different in that the elements they contain don't get their own line. You could surround one word in a paragraph with the span tags, and the word wouldn't get its own line.

You can give both divs and spans IDs/classes. :D

Once again, as I suspected, when we learn CSS we'll see more about how this works, as it's mostly useful with CSS.

Onward!!

Top comments (0)