This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Mathematica Import/Export Format

HTML (.html, .htm)

Registered MIME type: text/html
HTML markup language and file format.
Predominant language for the creation of web pages.
HTML is an acronym derived from Hypertext Markup Language.
Plain text format.
Describes the structure and aspects of the appearance of web pages.
First published in 1993 as an Internet Engineering Task Force (IETF) working draft.
Maintained since 1996 by the World Wide Web Consortium (W3C).
Most recent version is 4.01, published in 1999 as W3C recommendation.
International standard ISO/IEC 15445:2000.
Predecessor of XHTML.
  • Import fully supports HTML version 4.01.
  • Output from Export[..., "HTML"]conforms to the XHTML 1.1 standard.
  • Import["file.html"] gives a plain text representation of an HTML file.
  • Import["file.html", "Data"] extracts tabular data from HTML.
  • Export["file.html", expr] creates an HTML version of expr.
  • Export["dir", expr] translates expr to HTML, saving the output in the specified directory.
  • Import["file.html"] returns a string, representing the textual content of the file as formatted plain text.
  • Export["file.html", expr] exports a notebook, a cell, a list of cells, or other notebook elements to HTML.
  • Export always creates a complete HTML document, and not merely a fragment of HTML.
  • The output consists of one or more HTML files and two directories, HTMLFiles and HTMLLinks.
  • Mathematica by default converts typeset expressions to GIF images when exporting to HTML.
  • Mathematica can export Tooltip and Hyperlink expressions to HTML, creating HTML image maps if necessary.
  • Import["file.html", elem] imports the specified element from an HTML file.
  • Import["file.html", {elem, suba, subb, ...}] imports a subelement.
  • Import["file.html", {{elem1, elem2, ...}}] imports multiple elements.
  • The import format can be specified with Import["file", "HTML"] or Import["file", {"HTML", elem, ...}].
  • Export["file.html", expr, elem] creates an HTML file by treating expr as specifying element elem.
  • Export["file.html", {expr1, expr2, ...}, {{elem1, elem2, ...}}] treats each expri as specifying the corresponding elemi.
  • Export["file.html", expr, opt1->val1, ...] exports expr with the specified option elements taken to have the specified values.
  • Export["file.html", {elem1->expr1, elem2->expr2, ...}, "Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • Save Selection As exports the selected part of a notebook as a web page.
  • Save As exports an entire notebook as a web page.
"Elements"list of elements and options available in this file
"Rules"full list of rules for each element and option
"Options"list of rules for options, properties, and settings
"Data"textual and numerical content from HTML table and list elements
"FullData"full tabular content, including empty HTML table and list elements
"Hyperlinks"list of strings, representing target URLs of hyperlinks
"Plaintext"HTML document formatted as text
"Source"raw HTML source as a single string
"XMLObject"symbolic XML representation of the entire document
  • Import by default uses the "Plaintext" element.
  • When importing a plain HTML document as "XMLObject", Mathematica will attempt to convert it to well-formed XHTML and import the resulting XML file.
"Notebook"a Notebook expression
"NotebookObject"a NotebookObject expression
"Expression"an arbitrary Mathematica expression
"DefaultEncoding""UTF8"encoding to use if no character set is specified in the HTML source
"Numeric"Truewhether to import data fields as numbers when possible
  • If the character encoding of the file is not specified in the HTML file, Import uses the encoding specified by "DefaultEncoding". A complete list of possible encodings is given by $CharacterEncodings.
  • Mathematica always uses the UTF-8 encoding when exporting to HTML.
"ConvertLinkedNotebooks"Falsewhether to convert linked notebooks to HTML
"ConversionRules"Automaticspecifies mappings from Mathematica cell styles to HTML elements, including both inline and block-level versions of the markup
"CSS"Automaticwhat CSS stylesheet to use or link to
"HeadAttributes"{}attributes to be inserted in HTML <head> tag, given as a list of rules
"HeadElements"{}subelements of HTML <head> tag
"MathOutput""GIF"how to represent typeset expressions
"ConvertClosed"Truewhether to export forward-closed cell groups
"ConvertReverseClosed"Falsewhether to export reverse-closed cell groups
"Content"Falsewhether to export MathML content elements
  • Possible settings for "CSS" are:
Automaticcreates a CSS stylesheet from the Mathematica stylesheet
Nonedoes not create a stylesheet file or inline CSS style
"file.css"uses a stylesheet file
  • The following settings can be given for "MathOutput":
"GIF"converts all typeset expressions to GIF
"MathML"converts all typeset expressions to MathML
"DisplayForm"converts all typeset expressions to ASCII approximations of their appearance
"InputForm"converts all typeset expressions to their InputForm
  • Allowed settings for "ConvertClosed"and "ConvertReverseClosed" are:
Falsedoes not export closed groups
Trueexports all cell groups
"LinkedPage"exports each forward-closed group to a separate page