This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

HTML Tag Methods

Summary

You can use HTML tag methods to place HTML elements around text in a String object.

Syntax

Examples

The following examples show how to use the HTML tag methods.

// anchor method.
 var strVariable = "This is an anchor.";
 document.write(strVariable.anchor("Anchor1"));
 // Output: <A NAME="Anchor1">This is an anchor.</A>

 // big method.
 var strVariable = "This is a string.";
 document.write(strVariable.big());
 // Output: <BIG>This is a string.</BIG>

 //  blink method.
 var strVariable = "This is a string.";
 document.write(strVariable.blink());
 // Output: <BLINK>This is a string.</BLINK>

 //  bold method.
 var strVariable = "This is a string.";
 document.write(strVariable.bold());
 // Output: <B>This is a string.</B>

 //  fixed method.
 var strVariable = "This is a string.";
 document.write(strVariable.fixed());
 // Output: <TT>This is a string.</TT>

 //  fontcolor method.
 var strVariable = "This is a string.";
 document.write(strVariable.fontcolor("red"));
 // Output: <FONT COLOR="red">This is a string.</FONT>

 //  fontsize method.
 var strVariable = "This is a string.";
 document.write(strVariable.fontsize(-1));
 // Output: <FONT SIZE="-1">This is a string.</FONT>

 //  italics method
 var strVariable = "This is a string.";
 document.write(strVariable.italics());
 // Output: <I>This is a string.</I>

 //  link method.
 var strVariable = "This is a hyperlink.";
 document.write(strVariable.link("http://www.microsoft.com"));
 // Output: <A HREF="http://www.microsoft.com">This is a hyperlink.</A>

 //  small method.
 var strVariable = "This is a string.";
 document.write(strVariable.small());
 // Output: <SMALL>This is a string.</SMALL>

 //  strike method.
 var strVariable = "This is a string.";
 document.write(strVariable.strike());
 // Output: <STRIKE>This is a string.</STRIKE>

 //  sub method.
 var strVariable = "This is a string.";
 document.write(strVariable.sub());
 // Output: <SUB>This is a string.</SUB>

 //  sup method.
 var strVariable = "This is a string.";
 document.write(strVariable.sup());
 // Output: <SUP>This is a string.</SUP>

Remarks

No checking is performed to determine whether the HTML tags have already been applied to the string.

Syntax

The following table lists the syntax for and a description of each HTML tag method.

In the Syntax column, string1 is a String object or literal.

The Standard column indicates World Wide Web Consortium (W3C) recommendations for HTML 4. “Discouraged” indicates that the HTML element is discouraged in favor of style sheets.

Syntax Method description Parameter description Standard
string1.anchor( name ) Places an HTML anchor that has a NAME attribute around the text. The name parameter is text to put in the NAME attribute of the HTML anchor.
string1.big() Places HTML \ tags around the text. Discouraged
string1.blink() Places HTML \ tags around the text. The \ tag is not supported in Internet Explorer. Not in standard
string1.bold() Places HTML \ tags around the text. Discouraged
string1.fixed() Places HTML \ tags around the text. Discouraged
string1.fontcolor( color ) Places HTML \ tags with a COLOR attribute around the text. The color parameter is a string value that contains the hexadecimal value or predefined name for a color. Valid predefined color names depend on the JavaScript host browser and its version. Deprecated
string1.fontsize( size ) Places HTML \ tags with a SIZE attribute around the text. The size parameter is an integer value that specifies the size of the text. Valid integer values depend on the JavaScript host browser and its version. Deprecated
string1.italics() Places HTML \ tags around the text. Discouraged
string1.link( href ) Places an HTML anchor that has an HREF attribute around the text. The href parameter is text to put in the HREF attribute of the HTML anchor.
string1.small() Places HTML \ tags around the text. Discouraged
string1.strike() Places HTML \ tags around the text. Deprecated
string1.sub() Places HTML \ tags around the text.
string1.sup() Places HTML \ tags around the text.
## See also

Other articles

Attributions

  • Microsoft Developer Network: Article