• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

when should i use span when should I use div

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
rubbery bacon. crispy tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic