# Minify HTML
Learn how to minify HTML and CSS when rendering of documents into HTML and make your HTML documents load faster with GroupDocs.Viewer.
When you are looking for ways to optimize the rendering of documents to HTML, one of the solutions is the compression of the output content (HTML, CSS, and SVG). This is suitable if you provide your content from the web server over the Internet. The less the user has to download, the faster he accesses the rendered document.
{{< alert style="info" >}}Minification does not reduce content size as much as Gzip compression, so use it in addition to Gzip compression. {{< /alert >}}
## Minification
Minification provides the output that looks identically with the original content in all browsers, but minified HTML content does not pass strict HTML validation. The following describes the size reduction methods used in minification.
### HTML Minification
HTML minification includes the following:
* Complete removal of comments (except containing IE conditional statements).
* Conditional comments compression.
* Removal of spaces and line breaks inside the tags and between the tags.
* Simplification of document type declaration to ``.
* Removal of all HTML tag properties.
* Removal of protocol declarations like http:, https:, and javascript: from path values.
* Replace multiple spaces between words (except when they occur inside the pre or textarea tag) with a single space.
* Removal of quotes around tag property values (except inline events).
* Removal of default attributes for "script", "style" and "link" tags.
* Simplification of boolean attributes, so `` becomes ``.
### CSS Minification
CSS minification includes the following:
* Removal of all insignificant white spaces.
* Removal of all comments.
* Removal of all unnecessary semicolon separators.
* Reducing color values.
* Reducing integer representations by removing leading and trailing zeros.
* Removal of unit specifiers from numeric zero values.
## How to minify HTML and CSS
The [HtmlViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/htmlviewoptions) class has the [Minify](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/htmlviewoptions/minify/) boolean property that is a flag to minify the output content.
The following code snippet shows how to enable minification:
{{< tabs "minify-html">}}
{{< tab "C#" >}}
```csharp
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...
using (Viewer viewer = new Viewer("sample.docx"))
{
// Create view options.
var viewOptions = HtmlViewOptions.ForEmbeddedResources();
// Render the minified file.
viewOptions.Minify = true;
viewer.View(viewOptions);
}
```
{{< /tab >}}
{{< tab "VB.NET">}}
```vb
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...
Module Program
Sub Main(args As String())
Using viewer As Viewer = New Viewer("sample.docx")
' Create view options.
Dim viewOptions = HtmlViewOptions.ForEmbeddedResources()
' Render the minified file.
viewOptions.Minify = True
viewer.View(viewOptions)
End Using
End Sub
End Module
```
{{< /tab >}}
{{< tab "sample.docx" >}}
{{< tab-text >}}
`sample.docx` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/net/_sample_files/developer-guide/rendering-documents/rendering-to-html/minify-html/sample.docx) to download it.
{{< /tab-text >}}
{{< /tab >}}
{{< tab "minify-html.zip" >}}
```text
p_1.html (228 KB)
p_2.html (109 KB)
p_3.html (141 KB)
p_4.html (884 KB)
p_5.html (86 KB)
```
[Download full output](https://docs.groupdocs.com/viewer/net/_output_files/developer-guide/rendering-documents/rendering-to-html/minify-html/MinifyHtml/minify-html.zip)
{{< /tab >}}
{{< /tabs >}}