File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes when should i use span when should I use div Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "when should i use span when should I use div" Watch "when should i use span when should I use div" New topic
Author

when should i use span when should I use div

Wilson Mui
Ranch Hand

Joined: Apr 09, 2003
Posts: 140
I am only starting to learn javascripts, and html for that matter. I am using almost exlusively div tags, and I was just wondering when people use span and how do they differ? How do you take advantage of the differences. Is there some things you can do with div and not span and vice-versa? thanks for the info.
Fred Vaughn
Greenhorn

Joined: Mar 14, 2004
Posts: 5
There is technically no difference between the two in terms of scripting them by the means of JavaScript. If, however, you compare them in terms of how they render in the browser and the default CSS in which is applied to them, that's a different story. The <div> element is a block-level element meaning it sits on its own line; the <span> element, however, is an inline-level element meaning it doesn't sit on its own line and can sit next to other fellow inline-level elements.
So, to sum things up: there is only a difference in how they render. When accessing them via JavaScript, there really is no difference.
[ March 14, 2004: Message edited by: Fred Vaughn ]
 
 
subject: when should i use span when should I use div
 
Threads others viewed
span and div
Problem of Combo box overlapping the menus.
refresh document.write()
Positioning a DIV to TOP
loading...pls wait in Ajax
IntelliJ Java IDE