# Using the library

> The renderer follows the CSS Box Model. Box model is nothing but a tree of boxes, just as the tree of HTML, each of this boxes is represented by a very used class called CssBox. The start node is represented by the class HtmlContainer.

> All the known CSS properties apply to each of this boxes. Each box may contain any number of child boxes and just one parent. The only box that has no parent at all is the so called Html Container.

> The most common use

> ### HtmlPanel

> A panel that is ready to accept HTML code via its Text property.

> The only properties you need to know are: AutoScroll. Activates/Deactivates the auto-scroll capabilities as you know. It is set to true by default. Text. Gets/Sets the HTML source. The panel will update the bounds of the elements as you scroll or resize the control.

> ### HtmlLabel

> A label that is ready to accept HTML code via its Text property.

> The only properties you need to know are: . AutoSize. Sets the size of the label automatically if activated. Text. Gets/Sets the HTML source.

> ### HtmlToolTip

> Works exactly like the ToolTip you already know, with the little difference that this tooltip will render HTML on it.
> There are no properties here to learn. Use it just the way you use the ToolTip that comes with the framework. Internally, it just handles the OwnerDraw event.

> ### HtmlRender

> Use this static class to easily render small pieces of html directly using 'Graphics' object.
> For example it can be used to render html into an Image:

>     // Measure the size of the html to know the image size
>     SizeF size;
>     using (var gImg = new Bitmap(1, 1))
>     using (var g = Graphics.FromImage(gImg))
>     {
>         size = HtmlRender.Measure(g, html, 800);
>     }

>     // Render the html into the output image
>     var img = new Bitmap((int)size.Width, (int)size.Height);
>     using (var g = Graphics.FromImage(img))
>     {
>         g.Clear(Color.White);
>         HtmlRender.Render(g, html, 0, 0, 800);
>     }

>     img.Save(@"c:\html.png", ImageFormat.Png);

> ### HtmlContainer

> Low level handling of Html Renderer logic, this class is used by HtmlPanel, HtmlLabel, HtmlToolTip and HtmlRender.
> The class allows html layout and rendering without association to actual winforms control, thouse allowing to handle html rendering on any graphics object.
> Using this class will require the client to handle all propogation of mouse\keyboard events, layout/paint calls, scrolling offset and location/size/rectangle handling.
> A simple use of an Html Container to draw HTML would look like this:

>     // Create the Html Container
>     var c = new HtmlContainer();

>     // Set html to render
>     c.SetHtml("<div>hello <b>world</b></div>");

>     // Perform layout of the html
>     c.PerformLayout(graphics);

>     // Paint the HTML
>     c.PerformPaint(graphics);