Highlighting Text
[Previous] [Main] [Next]

 
html++ provides a number of classes to highlight and control the appearance of text. All of the classes inherit from htmlGroup, and can thus contain other html++ objects. With the exception of htmlCenter, no line breaks are added by the classes, so they can be inserted inline with other text or objects. The available classes include:  
 
htmlCenter      htmlBlink         htmlBold  
htmlStrong      htmlItalic         htmlEmphasized  
htmlUnderline      htmlStrike         htmlSubscript  
htmlSuperscript      htmlBlockQuote  
 
These objects can be combined to produce nearly any desired effect. For example, to obtain bold, italicized text, you might use the following:  
 
   page << htmlBold( htmlItalic( "bold, italic text" ) ) ;  
 
The htmlBlockQuote class is useful for indenting blocks of text. Most browsers add a blank line before and after blockquoted text.  
 
   page << "The following paragraph"  
        << htmlBlockQuote( "is indented" )  
        << "from the rest of the text." ;  
 

ex_highlighting2.gif  

 
 
Example
 
This example program demonstrates the text formatting classes.  
 
#include <stdio.h>  
#include <stdlib.h>  
#include <dcmicro/htmlpp/htmlpp.h>  
 
int main( void )  
{  
   htmlCgi   server ;  
   htmlPage  page( "html++ example application" ) ;  
   htmlBreak br ;  
 
   page << htmlCenter( "centered" ) << br  
        << htmlBlink( "blinking" ) << br  
        << htmlBold( "bold" ) << br  
        << htmlStrong( "strong" ) << br  
        << htmlItalic( "italic" ) << br  
        << htmlEmphasized( "emphasized" ) << br  
        << htmlUnderline( "underlined" ) << br  
        << htmlStrike( "strike-through" ) << br  
        << htmlSubscript( "subscript" ) << "text" << br  
        << htmlSuperscript("superscript") << "text" << br;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY>  
<CENTER>centered</CENTER><BR>  
<BLINK>blinking</BLINK><BR>  
<B>bold</B><BR>  
<STRONG>strong</STRONG><BR>  
<I>italic</I><BR>  
<EM>emphasized</EM><BR>  
<U>underlined</U><BR>  
<STRIKE>strike-through</STRIKE><BR>  
<SUB>subscript</SUB>text<BR>  
<SUP>superscript</SUP>text<BR>  
</BODY>  
</HTML>  
 

ex_highlighting.gif  



©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.