Home > Tutorials > HTML > DIV and SPAN
DIV and SPAN
Our webpage now contains a wide variety of elements. There's only one problem, though - there are no generic block or inline elements. For instance, what if I'd like to group a few related paragraphs together on my page? Or, what if I would like to bring out a section of text which isn't block-level, and there is no specific tag which I would like to apply? It's for these reasons that we have the following two tags:
- <div>
- Division. The <div> tag defines a division or a section in an HTML document. The <div> tag is often used to group block-elements to format them with styles.
- <span>
- Span. The <span> The <span> tag provides no visual change by itself. The <span> tag provides a way to add a hook to a part of a text or a part of a document.
As <div> and <span> tags are mostly used for styling, you will also want to make sure each tag has an appropriate id (only one instance with the same name) or class (multiple instances with the same name) attribute attached to each tag.
Excercise: Open "MyFirstPage.html". Get your current page ready for styling. Edit your current page by grouping related content with <div> tags, and add at least one <span> tag to some text which you would like to change the appearance of.
If your code looks like mine, you've succeeded, and can go on to another lesson.
Comment on this page:
Comments
No one has commented on this lesson yet. You can be the first!