The <SPAN>
element is used to apply a style to text which doesn't play any structural role, or where use of standard HTML elements is not desirable. For example, it may be useful for text to be highlighted by rendering it with a different background colour. For text such as this, using a standard HTML element such as <EM>
with an applied style, would possibly be inappropriate, because browsers that don’t support style sheets would render the text as italicised. The <SPAN>
element is recommended in such situations as other browsers simply ignore it.
The <SPAN>
element can be used within text blocks to apply a style as defined in a style sheet, according to a CLASS or ID attribute, or the STYLE can be specified within the <SPAN>
attribute. As with other elements used within the <BODY>
of a HTML document, <SPAN>
can also have a certain style applied to it in the style sheet definition.
e.g. If
.redtext : { color : #FF0000}
has been defined in a style sheet, then the following :
would render the some text<SPAN CLASS="redtext"> some red text</SPAN> some more text
some red text
section in red.
would do exactly the same
<SPAN STYLE="{color : #FF0000}">some red text</SPAN>
Internet Explorer also supports the use of the DIR attribute for specifying the reading direction of the text. Using :
<SPAN DIR="rtl">some right-to-left text</SPAN>
causes the text to be rendered, reading from right to left, instead of the standard left to right. Note that this only occurs on systems that support right to left text rendering, for example, Arabic and Hebrew systems.
See the Style Sheets topic for more information about style sheets.
Viewing the source of any page of this reference may also provide some clues. The <SPAN>
element is used quite extensively for setting the styles of various text.
TITLE="informational ToolTip"
The Internet Explorer 4.0 (and above) specific TITLE
attribute is used for informational purposes. If present, the value of the TITLE
attribute is presented as a ToolTip when the users mouse hovers over the <SPAN>
section.
LANG="language setting"
The LANG
attribute can be used to specify what language the <SPAN>
element is using. It accepts any valid ISO standard language abbreviation (for example "en"
for English, "de"
for German etc.) For more details, see the Document Localisation section for more details.
LANGUAGE="Scripting language"
The LANGUAGE
attribute can be used to expressly specify which scripting language Internet Explorer 4.0 uses to interpret any scripting information used in the <SPAN>
element. It can accept values of vbscript
, vbs
, javascript
or jscript
. The first two specify the scripting language as Visual Basic Script, the latter two specify it as using Javascript (the default scripting language used if no LANGUAGE
attribute is set.
CLASS="Style Sheet class name"
The CLASS
attribute is used to specify the <SPAN>
element as using a particular style sheet class. See the Style Sheets topic for details.
STYLE="In line style setting"
As well as using previously defined style sheet settings, the <SPAN>
element can have in-line stylings attached to it. See the Style Sheets topic for details.
ID="Unique element identifier"
The ID
attribute can be used to either reference a unique style sheet identifier, or to provide a unique name for the <SPAN>
element for scripting purposes. Any <SPAN>
element with an ID
attribute can be directly manipulated in script by referencing its ID
attribute, rather than working through the All collection to determine the element. See the Scripting introduction topic for more information.
DATAFLD
The DATAFLD
attribute can be used to specify a data column name from the Data source (see DATASRC
) that the <SPAN>
is bound to. For more information on the DATAFLD
attribute, see the Data Binding topic.
DATAFORMATAS
When the <SPAN>
element is data-bound, it can accept straight text, or HTML from the data source. The DATAFORMATAS
attribute should be set to "TEXT
" or "HTML
" accordingly. with DATAFORMATAS="HTML"
, the data provided for the <SPAN>
element is parsed and rendered when its displayed.
For more information on the DATAFORMATAS
attribute, see the Data Binding topic.
DATASRC
The DATASRC
attribute can be used to specify a data source that the <SPAN>
is bound to. For more information on the DATASRC
attribute, see the Data Binding topic.
Every <SPAN>
element in a document is an object that can be manipulated through scripting. Note that scripting of the <SPAN>
element/object is only supported by Internet Explorer 4.0 in its Dynamic HTML object model. Netscape does not support direct scripting of the <SPAN>
element at all.
<SPAN...>
Properties
The <SPAN...>
element/object supports all of the standard Dynamic HTML properties (i.e. className, document, id, innerHTML, innerText, isTextEdit, lang, language, offsetHeight, offsetLeft, offsetParent, offsetTop, offsetWidth, outerHTML, outerText, parentElement, parentTextEdit, sourceIndex, style, tagName and title). Details of these can be found in the standard Dynamic HTML properties topics.
The <SPAN>
element also supports the following properties:
clientHeight
The clientHeight
property reflects the height (in pixels) of the contents of the <SPAN>
element.
clientWidth
The clientWidth
property reflects the width (in pixels) of the contents of the <SPAN>
element.
scrollHeight
The scrollHeight
property reflects the contents of the <SPAN>
elements total scrollable height (in pixels).
scrollLeft
The scrollLeft
property reflects a value representing the distance between the left-most edge of the element and the left-most visible edge of the element. While the contents of the <SPAN>
element are totally visible on the screen, the scrollLeft
property is 0, only increasing if the left-most edge of the <SPAN>
elements contents are scrolled off the left hand edge of the current viewing window.
scrollTop
The scrollTop
property returns a value that represents the distance between the top-most edge of the element and the top-most edge of the current viewing window. When used with the <SPAN>
element, the scrollTop
property is a value indicative of the extent to which the referenced element has been scrolled vertically. If the contents of the <SPAN>
element are visible, then the scrollTop
property will be 0, only increasing as the contents of the element are scrolled off the top of the current viewing window.
scrollWidth
Like the scrollHeight
property, the scrollWidth
property reflects a value that represents the total scrollable width of the contents of the <SPAN>
element.
<SPAN...>
Methods
The <SPAN...>
element/object supports all of the standard Dynamic HTML methods (i.e. click, contains, getAttribute, insertAdjacentHTML, insertAdjacentText, removeAttribute, scrollIntoView and setAttribute). Details of these can be found in the standard Dynamic HTML Methods topics.
<SPAN...>
Events
The <SPAN...>
element/object supports all of the standard Dynamic HTML events (i.e. onclick, ondblclick, ondragstart, onfilterchange, onhelp, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup and onselectstart). Details of these can be found in the standard Dynamic HTML events topics.
© 1995-1998, Stephen Le Hunte
Comments:
See also:
file: /Techref/language/html/ib/Text_Formatting/span.htm, 13KB, , updated: 2009/8/26 14:41, local time: 2024/8/14 14:23,
52.14.147.215:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/techref/language/html/ib/Text_Formatting/span.htm"> <SPAN></A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.