DEV Community

Joel Diharce
Joel Diharce

Posted on

2 1

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!!

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay