XHTML and CSS - Span
Span
In this tutorial we're going to be learning about the XHTML span tag, first I need to explain something else to show why the span tag is useful. Let's say you have a paragraph and you want to make a part of the text in that paragraph look different, if you style the paragraph element you would change the whole paragraph so that wouldn't work, but there is a way to do this using the span tag.
<html> <head> <title> This is the title. </title> <style type="text/css"> </style> </head> <body> <p>This is <span>a random</span> paragraph.</p> </body> </html>
When you view that in your browser you'll see that it just looks like a normal paragraph and that the span tag has not moved anything, let's make the background color and the text color in the span tag different.
<html> <head> <title> This is the title. </title> <style type="text/css"> span { background-color: red; color: white; } </style> </head> <body> <p>This is <span>a random</span> paragraph.</p> </body> </html>
When you view that you'll see that only the text between the span tags has been effected.

Page generated in 0.0063 seconds.