Paragraphs and Breaks
[Previous] [Main] [Next]

 
The htmlParagraph class is used to mark and separate paragraphs of text. It encapsulates the HTML <P> tag, which most browsers interpret by adding a blank line after the paragraph. Paragraph contents can be aligned left, right, centered, or justified via the Align() method.  
 
The htmlBreak class is also used to separate blocks of text (or other page elements), but differs in that it does not add a blank line. htmlBreak encapsulates the HTML <BR> tag. Many applications use htmlBreak frequently, so it's often convenient to create a local htmlBreak object as shown in the example below.  
 
htmlParagraph inherits from htmlGroup, so other html++ objects can be added to it using the base-class Add() method or << insertion operator. htmlBreak, on the other hand, is based on htmlObject instead of htmlGroup. htmlBreak is intended to be added to other objects.  
 
Example
 
#include <stdio.h>  
#include <stdlib.h>  
#include <dcmicro/htmlpp/htmlpp.h>  
 
int main( void )  
{  
   htmlCgi   server ;  
   htmlPage  page( "html++ example application" ) ;  
 
   //  Create a break object for convenience  
   htmlBreak  br ;  
 
   //  Create a paragraph object, adding some text to it  
   htmlParagraph  p ;  
   p << "This is one paragraph." ;  
 
   page << "The htmlBreak object causes a line break"  
        << htmlBreak()  
        << "without adding an extra blank line." << br   
        << p  
        << htmlParagraph( "This is another paragraph." ) ;  
 
   server << page ;  
   return 0 ;  
}  
 
Program Output
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY>  
The htmlBreak object causes a line break<BR>  
without adding an extra blank line.<BR>  
<P>This is one paragraph.</P>  
<P>This is another paragraph.</P>  
</BODY>  
</HTML>  
 
ex_paragraph.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.