A HyperText Markup Language (HTML) preview involves using a software application, script or plug-in to read a document written in HTML and produce a formatted rendering of the code, including elements such as images, cascading style sheets (CSS) and other non-text components. An HTML preview can be different from the normal rendering performed in a browser, because some elements might be shown only as placeholders and the actual rendering methods used could be more lightweight to allow for fast, dynamic changes. Some of the uses for an HTML preview include real-time display of HTML code during design and development, checking margins and content before printing, and creating thumbnail images for navigation or browsing. In some applications, the software components used to generate an HTML preview are exactly the same as those used to show a page in a web browser.
When a web site is being designed and coded, the actual HTML document is really just a collection of tags, numbers and commands. Images, interactive scripts and formatting specifications are stored as lines of text. When an HTML page is loaded to be viewed by a user, the text is parsed and images are loaded and buffered in memory. By progressively applying each of the HTML codes to a document, the sometimes complex and precise layout of the web page can be revealed.
The rendering components for certain web browsers are actually abstracted libraries that can be called from applications and programs outside the browser. This means a simple way to create an HTML preview is to load an HTML file and then pass it to the rendering components of an existing browser on a computer, which can then draw the page as it should be seen into a visible canvas on the screen. Once the HTML preview has been generated, the canvas on which it was drawn can be manipulated as if it were a simple image.
HTML editing programs that are used to create web pages can use an HTML preview window to show changes to the appearance of a site as the code is actively modified in another window. The rendered image of the page also can be sent to a printer, image file or other device — whether real or virtual — so it can be saved without the need to continually re-interpret the HTML. Web pages that are used for learning or creation can even use scripts that allow users to interact with HTML code that is instantly parsed directly on the site.
One difficulty that can occur when using an HTML preview is that it might not allow certain elements of the page to be displayed if the source of the information is not located locally. This could cause streaming media from a third-party source or advertising banners to be left blank. Also, some plug-ins might not work in an HTML preview, so scripts and applets that generate visual components might not be rendered at all.