{"route":"/en-US-v0.13.1/reference/html/","title":"HTML","description":"Documentation for functions related to HTML in Typst.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"exporting-as-html","name":"Exporting as HTML","children":[{"id":"command-line","name":"Command Line","children":[]},{"id":"web-app","name":"Web App","children":[]}]},{"id":"html-specific-functionality","name":"HTML-specific functionality","children":[]},{"id":"definitions","name":"Definitions","children":[]}],"body":{"kind":"category","content":{"name":"html","title":"HTML","details":"<div class=\"info-box\">\n<p>Typst's HTML export is currently under active development. The feature is still\nvery incomplete and only available for experimentation behind a feature flag. Do\nnot use this feature for production use cases. In the CLI, you can experiment\nwith HTML export by passing <code>--features html</code> or setting the <code>TYPST_FEATURES</code>\nenvironment variables to <code>html</code>. In the web app, HTML export is not available at\nthis time. Visit the <a href=\"https://github.com/typst/typst/issues/5512\">tracking issue</a>\nto follow progress on HTML export and learn more about planned features.</p>\n</div>\n<p>HTML files describe a document structurally. The aim of Typst's HTML export is\nto capture the structure of an input document and produce semantically rich HTML\nthat retains this structure. The resulting HTML should be accessible,\nhuman-readable, and editable by hand and downstream tools.</p>\n<p>PDF, PNG, and SVG export, in contrast, all produce <em>visual</em> representations of a\nfully-laid out document. This divergence in the formats' intents means that\nTypst cannot simply produce perfect HTML for your existing Typst documents. It\ncannot always know what the best semantic HTML representation of your content\nis.</p>\n<p>Instead, it gives <em>you</em> full control: You can check the current export format\nthrough the <a href=\"/en-US-v0.13.1/reference/foundations/target/\" title=\"`target`\"><code>target</code></a> function and when it is set to HTML, generate <a href=\"/en-US-v0.13.1/reference/html/elem/\">raw HTML\nelements</a>. The primary intended use of these elements is in\ntemplates and show rules. This way, the document's contents can be fully\nagnostic to the export target and content can be shared between PDF and HTML\nexport.</p>\n<p>Currently, Typst will always output a single HTML file. Support for outputting\ndirectories with multiple HTML documents and assets, as well as support for\noutputting fragments that can be integrated into other HTML documents is\nplanned.</p>\n<p>Typst currently does not output CSS style sheets, instead focussing on emitting\nsemantic markup. You can of course write your own CSS styles and still benefit\nfrom sharing your <em>content</em> between PDF and HTML. For the future, we plan to\ngive you the option of automatically emitting CSS, taking more of your existing\nset rules into account.</p>\n<h2 id=\"exporting-as-html\">Exporting as HTML</h2>\n<h3 id=\"command-line\">Command Line</h3>\n<p>Pass <code>--format html</code> to the <code>compile</code> or <code>watch</code> subcommand or provide an output\nfile name that ends with <code>.html</code>. Note that you must also pass <code>--features html</code>\nor set <code>TYPST_FEATURES=html</code> to enable this experimental export target.</p>\n<p>When using <code>typst watch</code>, Typst will spin up a live-reloading HTTP server. You\ncan configure it as follows:</p>\n<ul>\n<li>Pass <code>--port</code> to change the port. (Defaults to the first free port in the\nrange 3000-3005.)</li>\n<li>Pass <code>--no-reload</code> to disable injection of a live reload script. (The HTML\nthat is written to disk isn't affected either way.)</li>\n<li>Pass <code>--no-serve</code> to disable the server altogether.</li>\n</ul>\n<h3 id=\"web-app\">Web App</h3>\n<p>Not currently available.</p>\n<h2 id=\"html-specific-functionality\">HTML-specific functionality</h2>\n<p>Typst exposes HTML-specific functionality in the global <code>html</code> module. See below\nfor the definitions it contains.</p>","items":[{"name":"elem","route":"/en-US-v0.13.1/reference/html/elem/","oneliner":"An HTML element that can contain Typst content.","code":true},{"name":"frame","route":"/en-US-v0.13.1/reference/html/frame/","oneliner":"An element that lays out its content as an inline SVG.","code":true}],"shorthands":null}}}