<DIV> Is usually used to define areas of the page which can then be positioned and styled with CSS. You don't have to position them of course but it is becoming commonplace to use CSS-positioning as a better alternative to using HTML tables for layout (which they were never intended for). It makes for much cleaner lighter code as well.
<SPAN> Is used "inline", for example you might use it to highlight a few words in a sentence and style the class in a different colour for example.
e.g. This is an <span class="hilite">example of how you</span> might use <SPAN>. Obviously that won't actually do anything to the text in this example but you get the idea.
I would then have a CSS rule something like this:
.hilite {
color: #ff0000;
font-weight: bold;
}
which would make the words surrounded by the <span> bold and red.
also note, as mentioned span is an inline element and should really be used this way.
DIV is a block level element, it expands to full width and will not sit along side another div unless you specifically define those divs to be inline (display:inline
div can hold any type of content, tables, forms, more divs etc but spans, as Bananas already explained, is more suitable for highlighting a few words etc
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.