I would like to ask for some simple examples showing the uses of . I\'ve seen them both used to mark a section of a pa
Just wanted to add some historical context to how there came to be span
vs div
History of span
:
On July 3, 1995, Benjamin C. W. Sittler proposes a generic text container tag for applying styles to certain blocks of text. The rendering is neutral except if used in conjunction of a stylesheet. There is a debate around versus about readability, meaning. Bert Bos is mentioning the extensibility nature of the element through the class attribute (with values such as city, person, date, etc.). Paul Prescod is worried that both elements will be abused. He is opposed to text mentionning that "any new element should be on an old one" and adding "If we create a tag with no semantics it can be used anywehere without ever being wrong. We must force authors to properly tag the semantics of their document. We must force editor vendors to make that choice explicit in their interfaces."
- Source (w3 wiki)
From the RFC draft that introduces span
:
First, a generic con- tainer is needed to carry the LANG and BIDI attributes in cases where no other element is appropriate; the SPAN ele- ment is introduced for that purpose.
- Source (IETF Draft)
History of div
:
DIV elements can be used to structure HTML documents as a hierarchy of divisions.
...
CENTER was introduced by Netscape before they added support for the HTML 3.0 DIV element. It is retained in HTML 3.2 on account of its widespread deployment.
HTML 3.2 Spec
In a nutshell, both elements arose out of a need for a more semantically-generic container. Span was proposed as a more generic replacement for a
element to style text. Div was proposed as a generic way to divide pages and had the added benefit of replacing the
tag for center-aligning content. Div has always been a block element because of its history as a page divider. Span has always been an inline element because its original purpose was text styling and today div and span have both arrived at being generic elements with default block and inline display properties respectively.