Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Html Span
KansukeKojima
post Feb 1 2008, 07:30 PM
Post #1


Privileged Member
*********

Group: [HOSTED]
Posts: 524
Joined: 13-October 06
From: Alberta, Canada
Member No.: 31,584



HTML Span

Description
The span tag is quite the handy tag to have at your disposal. You can use it for everything from Text Formating, to creating a scrollable text area. When combined with CSS it becomes an easy-to-use tool for making your website as uniform as possible, as your not bogged down with <div> tags for every heading and title on your website.

Try It Out

CODE
<html>
<body>
<div class="content">
<span class="heading1">
Heading or title goes here.
</span><br><br>
All the content inside the div tags go here
</div>
</body>
</html>


Above we have a very basic page. The <div class="content"> tag would be used to house the content of your page. The <span class="heading1"> would be used for a heading or title. When you combine this with CSS and give the content and heading1 objects some properties and values, you can quickly and efficiently create headings and titles for your website.

Next, we'll learn to create a scrollable text area using the span tag.

CODE
<html>
<body>
<div class="content">
<span class="heading1">
Heading or title goes here.
</span><br><br>

<span style="overflow: auto; width: 500; height: 500;">
<table border="0" width="100%" height="100%" cellpadding="2" cellspacing="0">
Your content goes here
</table>
</span>
</div>
</body>


In the above example, we have everything from before but now we have included a scrollable text area. What gives it the ability to scroll is the overflow: auto; component of the tag. This is quite useful when a text area can only be a certain size, but there may not be enough room for you to include all of the information you need to. Once the text exceeds the specified hieght, you will be able to scroll down and view more text!

This post has been edited by KansukeKojima: Feb 1 2008, 10:17 PM
Go to the top of the page
 
+Quote Post
jlhaslip
post Feb 1 2008, 09:21 PM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,874
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



Good to see a Tutorial on the lowly <span> tag. It rarely receives the attention it deserves.

'Span' is an In-line element in (x)html. A 'generic' Inline container much like a 'div' tag, except that div's are Block elements.

Using the Span tag as a 'Heading' identifier is not correct usage of the Span tag. For semantic mark-up, you should use the Heading <Hn> tags since the Heading tags impart more information about the structure of your page to the search Bots. And as for using the span tag as a 'marquee', a div tag is better suited for that purpose, too, since the span tag should be for 'In-line' content. You can expect that different Browsers will handle the height attribute differently, possibly throwing an error on validation of your page.
Go to the top of the page
 
+Quote Post
KansukeKojima
post Feb 1 2008, 10:27 PM
Post #3


Privileged Member
*********

Group: [HOSTED]
Posts: 524
Joined: 13-October 06
From: Alberta, Canada
Member No.: 31,584



Thanks jlhaslip. I do not have much knowledge of how browsers anylyze the code etc.... in the future, I may look into learning more about it as it will increase my code validility.... (don't think that is a word)...

I didn't even know there was and <hn> tag so I think that I'll go and replace all those span tags acting as headings on my website.

Also, I will probably place this tutorial on my website as it is.... or maybe I'll change it to one on general div, span, and heading use....

This post has been edited by KansukeKojima: Feb 1 2008, 10:29 PM
Go to the top of the page
 
+Quote Post
jlhaslip
post Feb 1 2008, 11:13 PM
Post #4


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,874
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



What I mean by saying "Hn" is "H" followed by a number (n).
Html recognizes 6 levels of Headings--- h1 to h6.
Go to the top of the page
 
+Quote Post
sonesay
post Feb 1 2008, 11:22 PM
Post #5


|||[ n00b King ]|||
*********

Group: [HOSTED]
Posts: 642
Joined: 20-June 07
From: Auckland
Member No.: 45,102



Span tags are great for controlling something you need inline. I'm not sure if I've been using it right but how I do my headers I use <Hn> for them. But say I need to futher change output in your heading line. Heres an example

Hello by author.

For the above example you would use a <Hn> with a nested <span> inside it for the 'by author' formatting. I beleive this is still correct usage of the span tag right? I mean I really think of other reasons why we have them.
Go to the top of the page
 
+Quote Post
bthaxor
post Feb 2 2008, 05:24 AM
Post #6


Advanced Member
*******

Group: [HOSTED]
Posts: 134
Joined: 30-October 07
From: Sydney, Australia
Member No.: 52,225
Spam Patrol



i personally love span tags.

the thing they have over divs is that span tags are so much more flexible. by this i mean that you can place span tags almost wherever you like. it is not possible to place two divs side by side without adding some extra code, however spans fit perfectly side by side; you can even place a span next to a div.

you can also place spans inside paragraphs/divs, and this is useful if you would like that text to still be a part of the paragraph, but have a different style.

PS: sonesay, sorry but i can't resist saving the right pic. of your signature to my computer. i may even be tempted to use it as a part of my sig, it is so truthful yet amusing wink.gif
Go to the top of the page
 
+Quote Post
hippiman
post Feb 2 2008, 06:07 PM
Post #7


Premium Member
********

Group: Members
Posts: 150
Joined: 9-April 07
From: Nebraska
Member No.: 41,301



This was really helpful. I had heard of inline and block elements before, but I never really decided to figure out what that meant.

Now I know why whenever I was adding div's it was messing with all of my pages.
Go to the top of the page
 
+Quote Post
KansukeKojima
post Feb 4 2008, 03:43 PM
Post #8


Privileged Member
*********

Group: [HOSTED]
Posts: 524
Joined: 13-October 06
From: Alberta, Canada
Member No.: 31,584



QUOTE(jlhaslip @ Feb 1 2008, 04:13 PM) *
What I mean by saying "Hn" is "H" followed by a number (n).
Html recognizes 6 levels of Headings--- h1 to h6.

haha.... ok yeah... I new about those... lol

EDIT::

Ok also, here is a way to create a iframe like thing by using some php with a span tag.

CODE
<html>
<body>
<div class="content">
<span class="heading1">
Heading or title goes here.
</span><br><br>

<span style="overflow: auto; width: 500; height: 500;">
<table border="0" width="100%" height="100%" cellpadding="2" cellspacing="0">
<?php
include ("whatever.html");
?>
</table>
</span>
</div>
</body>


So there you go... just use an include in between the span tags.... and there you go.... nice iframe like thing.. but a little easier to manage... because we all hate iframes don't we?

This post has been edited by KansukeKojima: Feb 4 2008, 07:08 PM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Html With Css(13)
  2. HTML tags and examples(37)
  3. Web Programming Tuts For The Beginner(8)
  4. Saint_michael Html Tips & Tricks Issue #1(1)
  5. Saint-michaels Html Tips And Tricks Issue # 2(2)
  6. Saint Michael Xhtml Tips And Tricks #1(3)
  7. Saint-michael Html Tips And Tricks Issue #3(0)
  8. Saint-michaels Html Tips And Tricks #4(12)
  9. Basic Html (for Us Kids)(23)