1. Technology

The SPAN Tag

By

Description of the SPAN Tag:

The <span> tag in XHTML is a tag that groupings of inline content (defined) within the content of a page. What this means is that a <span> tag defines portions of Web elements to make them easier to manage, style, and manipulate. You can use the <span> tag when you want to change the color of a single word. The <span> tag is a very powerful tool for Web developers because it is so open-ended. The span tag can do anything you want it to do.

HTML Definition of the SPAN Tag:

In order to use the <span> tag you need to know the HTML definition of the <span> tag. Some key tips:

  • The <span> tag is an inline-level element.
  • The <span> tag can only contain other inline elements like abbr, strong, or tt.
  • The <span> tag can be inside <p> tags or <div> tags.

Tips for Using the SPAN Tag:

  • The <span> tag doesn't do anything by itself. In fact, the only attribute that might affect the page is the title attribute, and that depends upon the Web browser.
  • Use span tags when you don't want any changes to the layout other than exactly what you specify in the styles of the span. For example, if you use a <div> or <p> most browsers will add space around the element, because they are block elements.
  • It's always a good idea to close your <span> tags as soon as you open them. Then place the contents within the element.
  • If you nest your <span> tags, be sure that you know where your content is going (in other words, which SPAN it should be part of).
Related Video
DIV and Span Tags
  1. About.com
  2. Technology
  3. Web Design / HTML
  4. HTML and XHTML
  5. XHTML
  6. HTML Tags
  7. The SPAN Tag - About.com Web Design / HTML

©2014 About.com. All rights reserved.