tidy (1)
Leading comments
tidy man page for the HTML Tidy
NAME
tidy - check, correct, and pretty-print HTML(5) filesSYNOPSIS
tidy [option ...] [file ...] [option ...] [file ...]DESCRIPTION
Tidy reads HTML, XHTML, and XML files and writes cleaned-up markup. For HTML variants, it detects, reports, and corrects many common coding errors and strives to produce visually equivalent markup that is both conformant to the HTML specifications and that works in most browsers.A common use of Tidy is to convert plain HTML to XHTML. For generic XML files, Tidy is limited to correcting basic well-formedness errors and pretty printing.
If no input file is specified, Tidy reads the standard input. If no output file is specified, Tidy writes the tidied markup to the standard output. If no error file is specified, Tidy writes messages to the standard error. For command line options that expect a numerical argument, a default is assumed if no meaningful value can be found.
OPTIONS
File manipulation
- -output <%s>, -o <%s>
- write output to the specified <file> (output-file: <%s>)
- -config <%s>
-
set configuration options from the specified <file>
- -file <%s>, -f <%s>
- write errors and warnings to the specified <file> (error-file: <%s>)
- -modify, -m
- modify the original input files (write-back: yes)
Processing directives
- -indent, -i
- indent element content (indent: auto)
- -wrap <%s>, -w <%s>
- wrap text at the specified <column>. 0 is assumed if <column> is missing. When this option is omitted, the default of the configuration option 'wrap' applies. (wrap: <%s>)
- -upper, -u
- force tags to upper case (uppercase-tags: yes)
- -clean, -c
- replace FONT, NOBR and CENTER tags with CSS (clean: yes)
- -bare, -b
- strip out smart quotes and em dashes, etc. (bare: yes)
- -gdoc, -g
- produce clean version of html exported by Google Docs (gdoc: yes)
- -numeric, -n
- output numeric rather than named entities (numeric-entities: yes)
- -errors, -e
- show only errors and warnings (markup: no)
- -quiet, -q
- suppress nonessential output (quiet: yes)
- -omit
- omit optional start tags and end tags (omit-optional-tags: yes)
- -xml
- specify the input is well formed XML (input-xml: yes)
- -asxml, -asxhtml
- convert HTML to well formed XHTML (output-xhtml: yes)
- -ashtml
- force XHTML to well formed HTML (output-html: yes)
- -access <%s>
- do additional accessibility checks (<level> = 0, 1, 2, 3). 0 is assumed if <level> is missing. (accessibility-check: <%s>)
Character encodings
- -raw
-
output values above 127 without conversion to entities
- -ascii
-
use ISO-8859-1 for input, US-ASCII for output
- -latin0
-
use ISO-8859-15 for input, US-ASCII for output
- -latin1
-
use ISO-8859-1 for both input and output
- -iso2022
-
use ISO-2022 for both input and output
- -utf8
-
use UTF-8 for both input and output
- -mac
-
use MacRoman for input, US-ASCII for output
- -win1252
-
use Windows-1252 for input, US-ASCII for output
- -ibm858
-
use IBM-858 (CP850+Euro) for input, US-ASCII for output
- -utf16le
-
use UTF-16LE for both input and output
- -utf16be
-
use UTF-16BE for both input and output
- -utf16
-
use UTF-16 for both input and output
- -big5
-
use Big5 for both input and output
- -shiftjis
-
use Shift_JIS for both input and output
Miscellaneous
- -version, -v
-
show the version of Tidy
- -help, -h, -?
-
list the command line options
- -help-config
-
list all configuration options
- -show-config
-
list the current configuration settings
- -help-option <%s>
-
show a description of the <option>
- -language <%s>
- set Tidy's output language to <lang>. Specify '-language help' for more help. Use before output-causing arguments to ensure the language takes effect, e.g.,`tidy -lang es -lang help`. (language: <%s>)
XML
- -xml-help
-
list the command line options in XML format
- -xml-config
-
list all configuration options in XML format
- -xml-strings
-
output all of Tidy's strings in XML format
- -xml-error-strings
-
output error constants and strings in XML format
- -xml-options-strings
-
output option descriptions in XML format
USAGE
Use --optionX valueX for the detailed configuration option "optionX" with argument "valueX". See also below under Detailed Configuration Options as to how to conveniently group all such options in a single config file.
Input/Output default to stdin/stdout respectively. Single letter options apart from -f and -o may be combined as in:
tidy -f errs.txt -imu foo.html
ENVIRONMENT
- HTML_TIDY
- Name of the default configuration file. This should be an absolute path, since you will probably invoke tidy from different directories. The value of HTML_TIDY will be parsed after the compiled-in default (defined with -DTIDY_CONFIG_FILE), but before any of the files specified using -config.
EXIT STATUS
- 0
- All input files were processed successfully.
- 1
- There were warnings.
- 2
-
There were errors.
______________________________
DETAILED CONFIGURATION OPTIONS
This section describes the Detailed (i.e., "expanded") Options, which may be specified by preceding each option with -- at the command line, followed by its desired value, OR by placing the options and values in a configuration file, and telling tidy to read that file with the -config standard option.SYNOPSIS
tidy --option1 value1 --option2 value2 [standard options ...]tidy -config config-file [standard options ...]
WARNING
The options detailed here do not include the "standard" command-line options (i.e., those preceded by a single '-') described above in the first section of this man page.DESCRIPTION
A list of options for configuring the behavior of Tidy, which can be passed either on the command line, or specified in a configuration file.A Tidy configuration file is simply a text file, where each option is listed on a separate line in the form
option1: value1
option2: value2
etc.
The permissible values for a given option depend on the option's Type. There are five types: Boolean, AutoBool, DocType, Enum, and String. Boolean types allow any of yes/no, y/n, true/false, t/f, 1/0. AutoBools allow auto in addition to the values allowed by Booleans. Integer types take non-negative integers. String types generally have no defaults, and you should provide them in non-quoted form (unless you wish the output to contain the literal quotes).
Enum, Encoding, and DocType "types" have a fixed repertoire of items; consult the Example[s] provided below for the option[s] in question.
You only need to provide options and values for those whose defaults you wish to override, although you may wish to include some already-defaulted options and values for the sake of documentation and explicitness.
Here is a sample config file, with at least one example of each of the five Types:
// sample Tidy configuration options
output-xhtml: yes
add-xml-decl: no
doctype: strict
char-encoding: ascii
indent: auto
wrap: 76
repeated-attributes: keep-last
error-file: errs.txt
Below is a summary and brief description of each of the options. They are listed alphabetically within each category. There are five categories: HTML, XHTML, XML options, Diagnostics options, Pretty Print options, Character Encoding options, and Miscellaneous options.
OPTIONS
HTML, XHTML, XML options:
- add-xml-decl
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should add the XML declaration when outputting XML or XHTML.Note that if the input already includes an <?xml ... ?> declaration then this option will be ignored.
If the encoding for the output is different from ascii, one of the utf* encodings, or raw, then the declaration is always added as required by the XML standard.
See also: char-encoding, output-encoding - add-xml-space
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should add xml:space="preserve" to elements such as <pre>, <style> and <script> when generating XML.This is needed if the whitespace in such elements is to be parsed appropriately without having access to the DTD.
- alt-text
-
Type: String
Default: -
Default: -
This option specifies the default alt= text Tidy uses for <img> attributes when the alt= attribute is missing.Use with care, as it is your responsibility to make your documents accessible to people who cannot see the images.
- anchor-as-name
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option controls the deletion or addition of the name attribute in elements where it can serve as anchor.If set to yes a name attribute, if not already existing, is added along an existing id attribute if the DTD allows it.
If set to no any existing name attribute is removed if an id attribute exists or has been added.
- assume-xml-procins
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should change the parsing of processing instructions to require ?> as the terminator rather than >.This option is automatically set if the input is in XML.
- bare
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should strip Microsoft specific HTML from Word 2000 documents, and output spaces rather than non-breaking spaces where they exist in the input. - clean
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should perform cleaning of some legacy presentational tags (currently <i>, <b>, <center> when enclosed within appropriate inline tags, and <font>). If set to yes then legacy tags will be replaced with CSS <style> tags and structural markup as appropriate. - coerce-endtags
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should coerce a start tag into an end tag in cases where it looks like an end tag was probably intended; for example, given<span>foo <b>bar<b> baz</span>
Tidy will output
<span>foo <b>bar</b> baz</span>
- css-prefix
-
Type: String
Default: -
Default: -
This option specifies the prefix that Tidy uses for styles rules.By default, c will be used.
- decorate-inferred-ul
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should decorate inferred <ul> elements with some CSS markup to avoid indentation to the right. - doctype
-
Type: DocType
Default: auto
Example: html5, omit, auto, strict, transitional, user
This option specifies the DOCTYPE declaration generated by Tidy.If set to omit the output won't contain a DOCTYPE declaration. Note this this also implies numeric-entities is set to yes.
If set to html5 the DOCTYPE is set to <!DOCTYPE html>.
If set to auto (the default) Tidy will use an educated guess based upon the contents of the document.
If set to strict, Tidy will set the DOCTYPE to the HTML4 or XHTML1 strict DTD.
If set to loose, the DOCTYPE is set to the HTML4 or XHTML1 loose (transitional) DTD.
Alternatively, you can supply a string for the formal public identifier (FPI).
For example:
doctype: "-//ACME//DTD HTML 3.14159//EN"
If you specify the FPI for an XHTML document, Tidy will set the system identifier to an empty string. For an HTML document, Tidy adds a system identifier only if one was already present in order to preserve the processing mode of some browsers. Tidy leaves the DOCTYPE for generic XML documents unchanged.
This option does not offer a validation of document conformance.
- drop-empty-elements
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should discard empty elements. - drop-empty-paras
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should discard empty paragraphs. - drop-font-tags
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
Deprecated; do not use. This option is destructive to <font> tags, and it will be removed from future versions of Tidy. Use the clean option instead.If you do set this option despite the warning it will perform as clean except styles will be inline instead of put into a CSS class. <font> tags will be dropped completely and their styles will not be preserved.
If both clean and this option are enabled, <font> tags will still be dropped completely, and other styles will be preserved in a CSS class instead of inline.
See clean for more information.
- drop-proprietary-attributes
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should strip out proprietary attributes, such as Microsoft data binding attributes. Additionally attributes that aren't permitted in the output version of HTML will be dropped if used with strict-tags-attributes. - enclose-block-text
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should insert a <p> element to enclose any text it finds in any element that allows mixed content for HTML transitional but not HTML strict. - enclose-text
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should enclose any text it finds in the body element within a <p> element.This is useful when you want to take existing HTML and use it with a style sheet.
- escape-cdata
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should convert <![CDATA[]]> sections to normal text. - fix-backslash
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should replace backslash characters \ in URLs with forward slashes /. - fix-bad-comments
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should replace unexpected hyphens with = characters when it comes across adjacent hyphens.The default is yes.
This option is provided for users of Cold Fusion which uses the comment syntax: <!--- --->.
- fix-uri
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should check attribute values that carry URIs for illegal characters and if such are found, escape them as HTML4 recommends. - gdoc
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should enable specific behavior for cleaning up HTML exported from Google Docs. - hide-comments
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should print out comments. - hide-endtags
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option is an alias for omit-optional-tags. - indent-cdata
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should indent <![CDATA[]]> sections. - input-xml
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should use the XML parser rather than the error correcting HTML parser. - join-classes
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should combine class names to generate a single, new class name if multiple class assignments are detected on an element. - join-styles
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should combine styles to generate a single, new style if multiple style values are detected on an element. - literal-attributes
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies how Tidy deals with whitespace characters within attribute values.If the value is no Tidy normalizes attribute values by replacing any newline or tab with a single space, and further by replacing any contiguous whitespace with a single space.
To force Tidy to preserve the original, literal values of all attributes and ensure that whitespace within attribute values is passed through unchanged, set this option to yes.
- logical-emphasis
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should replace any occurrence of <i> with <em> and any occurrence of <b> with <strong>. Any attributes are preserved unchanged.This option can be set independently of the clean option.
- lower-literals
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should convert the value of an attribute that takes a list of predefined values to lower case.This is required for XHTML documents.
- merge-divs
-
Type: AutoBool
Default: auto
Example: auto, y/n, yes/no, t/f, true/false, 1/0
This option can be used to modify the behavior of clean when set to yes.This option specifies if Tidy should merge nested <div> such as <div><div>...</div></div>.
If set to auto the attributes of the inner <div> are moved to the outer one. Nested <div> with id attributes are not merged.
If set to yes the attributes of the inner <div> are discarded with the exception of class and style.
See also: clean, merge-spans - merge-emphasis
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should merge nested <b> and <i> elements; for example, for the case<b class="rtop-2">foo <b class="r2-2">bar</b> baz</b>,
Tidy will output <b class="rtop-2">foo bar baz</b>.
- merge-spans
-
Type: AutoBool
Default: auto
Example: auto, y/n, yes/no, t/f, true/false, 1/0
This option can be used to modify the behavior of clean when set to yes.This option specifies if Tidy should merge nested <span> such as <span><span>...</span></span>.
The algorithm is identical to the one used by merge-divs.
See also: clean, merge-divs - ncr
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should allow numeric character references. - new-blocklevel-tags
-
Type: Tag names
Default: -
Example: tagX, tagY, ...
This option specifies new block-level tags. This option takes a space or comma separated list of tag names.Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags.
Note you can't change the content model for elements such as <table>, <ul>, <ol> and <dl>.
This option is ignored in XML mode.
See also: new-empty-tags, new-inline-tags, new-pre-tags - new-empty-tags
-
Type: Tag names
Default: -
Example: tagX, tagY, ...
This option specifies new empty inline tags. This option takes a space or comma separated list of tag names.Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags.
Remember to also declare empty tags as either inline or blocklevel.
This option is ignored in XML mode.
See also: new-blocklevel-tags, new-inline-tags, new-pre-tags - new-inline-tags
-
Type: Tag names
Default: -
Example: tagX, tagY, ...
This option specifies new non-empty inline tags. This option takes a space or comma separated list of tag names.Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags.
This option is ignored in XML mode.
See also: new-blocklevel-tags, new-empty-tags, new-pre-tags - new-pre-tags
-
Type: Tag names
Default: -
Example: tagX, tagY, ...
This option specifies new tags that are to be processed in exactly the same way as HTML's <pre> element. This option takes a space or comma separated list of tag names.Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags.
Note you cannot as yet add new CDATA elements.
This option is ignored in XML mode.
See also: new-blocklevel-tags, new-empty-tags, new-inline-tags - numeric-entities
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should output entities other than the built-in HTML entities (&, <, >, and ") in the numeric rather than the named entity form.Only entities compatible with the DOCTYPE declaration generated are used.
Entities that can be represented in the output encoding are translated correspondingly.
See also: doctype, preserve-entities - omit-optional-tags
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should omit optional start tags and end tags when generating output.Setting this option causes all tags for the <html>, <head>, and <body> elements to be omitted from output, as well as such end tags as </p>, </li>, </dt>, </dd>, </option>, </tr>, </td>, and </th>.
This option is ignored for XML output.
- output-html
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should generate pretty printed output, writing it as HTML. - output-xhtml
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should generate pretty printed output, writing it as extensible HTML.This option causes Tidy to set the DOCTYPE and default namespace as appropriate to XHTML, and will use the corrected value in output regardless of other sources.
For XHTML, entities can be written as named or numeric entities according to the setting of numeric-entities.
The original case of tags and attributes will be preserved, regardless of other options.
- output-xml
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should pretty print output, writing it as well-formed XML.Any entities not defined in XML 1.0 will be written as numeric entities to allow them to be parsed by an XML parser.
The original case of tags and attributes will be preserved, regardless of other options.
- preserve-entities
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should preserve well-formed entities as found in the input. - quote-ampersand
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should output unadorned & characters as &. - quote-marks
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should output " characters as " as is preferred by some editing environments.The apostrophe character ' is written out as ' since many web browsers don't yet support '.
- quote-nbsp
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should output non-breaking space characters as entities, rather than as the Unicode character value 160 (decimal). - repeated-attributes
-
Type: enum
Default: keep-last
Example: keep-first, keep-last
This option specifies if Tidy should keep the first or last attribute, if an attribute is repeated, e.g. has two align attributes.
See also: join-classes, join-styles - replace-color
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should replace numeric values in color attributes with HTML/XHTML color names where defined, e.g. replace #ffffff with white. - show-body-only
-
Type: AutoBool
Default: no
Example: auto, y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should print only the contents of the body tag as an HTML fragment.If set to auto, this is performed only if the body tag has been inferred.
Useful for incorporating existing whole pages as a portion of another page.
This option has no effect if XML output is requested.
- skip-nested
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies that Tidy should skip nested tags when parsing script and style data. - strict-tags-attributes
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This options ensures that tags and attributes are applicable for the version of HTML that Tidy outputs. When set to yes (the default) and the output document type is a strict doctype, then Tidy will report errors. If the output document type is a loose or transitional doctype, then Tidy will report warnings.Additionally if drop-proprietary-attributes is enabled, then not applicable attributes will be dropped, too.
When set to no, these checks are not performed.
- uppercase-attributes
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should output attribute names in upper case.The default is no, which results in lower case attribute names, except for XML input, where the original case is preserved.
- uppercase-tags
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should output tag names in upper case.The default is no which results in lower case tag names, except for XML input where the original case is preserved.
- word-2000
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should go to great pains to strip out all the surplus stuff Microsoft Word 2000 inserts when you save Word documents as "Web pages". It doesn't handle embedded images or VML.You should consider using Word's "Save As: Web Page, Filtered".
Diagnostics options:
- accessibility-check
-
Type: enum
Default: 0 (Tidy Classic)
Example: 0 (Tidy Classic), 1 (Priority 1 Checks), 2 (Priority 2 Checks), 3 (Priority 3 Checks)
This option specifies what level of accessibility checking, if any, that Tidy should perform.Level 0 (Tidy Classic) is equivalent to Tidy Classic's accessibility checking.
For more information on Tidy's accessibility checking, visit Tidy's Accessibility Page at www.html-tidy.org/accessibility.
- show-errors
-
Type: Integer
Default: 6
Example: 0, 1, 2, ...
This option specifies the number Tidy uses to determine if further errors should be shown. If set to 0, then no errors are shown. - show-info
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should display info-level messages. - show-warnings
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should suppress warnings. This can be useful when a few errors are hidden in a flurry of warnings.
Pretty Print options:
- break-before-br
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should output a line break before each <br> element. - escape-scripts
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option causes items that look like closing tags, like </g to be escaped to <\/g. Set this option to 'no' if you do not want this. - indent
-
Type: AutoBool
Default: no
Example: auto, y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should indent block-level tags.If set to auto Tidy will decide whether or not to indent the content of tags such as <title>, <h1>-<h6>, <li>, <td>, or <p> based on the content including a block-level element.
Setting indent to yes can expose layout bugs in some browsers.
Use the option indent-spaces to control the number of spaces or tabs output per level of indent, and indent-with-tabs to specify whether spaces or tabs are used.
See also: indent-spaces - indent-attributes
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should begin each attribute on a new line. - indent-spaces
-
Type: Integer
Default: 2
Example: 0, 1, 2, ...
This option specifies the number of spaces or tabs that Tidy uses to indent content when indent is enabled.Note that the default value for this option is dependent upon the value of indent-with-tabs (see also).
See also: indent - indent-with-tabs
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should indent with tabs instead of spaces, assuming indent is yes.Set it to yes to indent using tabs instead of the default spaces.
Use the option indent-spaces to control the number of tabs output per level of indent. Note that when indent-with-tabs is enabled the default value of indent-spaces is reset to 1.
Note tab-size controls converting input tabs to spaces. Set it to zero to retain input tabs.
- markup
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should generate a pretty printed version of the markup. Note that Tidy won't generate a pretty printed version if it finds significant errors (see force-output). - punctuation-wrap
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should line wrap after some Unicode or Chinese punctuation characters. - sort-attributes
-
Type: enum
Default: none
Example: none, alpha
This option specifies that Tidy should sort attributes within an element using the specified sort algorithm. If set to alpha, the algorithm is an ascending alphabetic sort. - split
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option has no function and is deprecated. - tab-size
-
Type: Integer
Default: 8
Example: 0, 1, 2, ...
This option specifies the number of columns that Tidy uses between successive tab stops. It is used to map tabs to spaces when reading the input. - vertical-space
-
Type: AutoBool
Default: no
Example: auto, y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should add some extra empty lines for readability.The default is no.
If set to auto Tidy will eliminate nearly all newline characters.
- wrap
-
Type: Integer
Default: 68
Example: 0 (no wrapping), 1, 2, ...
This option specifies the right margin Tidy uses for line wrapping.Tidy tries to wrap lines so that they do not exceed this length.
Set wrap to 0(zero) if you want to disable line wrapping.
- wrap-asp
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should line wrap text contained within ASP pseudo elements, which look like: <% ... %>. - wrap-attributes
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should line-wrap attribute values, meaning that if the value of an attribute causes a line to exceed the width specified by wrap, Tidy will add one or more line breaks to the value, causing it to be wrapped into multiple lines.Note that this option can be set independently of wrap-script-literals. By default Tidy replaces any newline or tab with a single space and replaces any sequences of whitespace with a single space.
To force Tidy to preserve the original, literal values of all attributes, and ensure that whitespace characters within attribute values are passed through unchanged, set literal-attributes to yes.
See also: wrap-script-literals, literal-attributes - wrap-jste
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should line wrap text contained within JSTE pseudo elements, which look like: <# ... #>. - wrap-php
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should line wrap text contained within PHP pseudo elements, which look like: <?php ... ?>. - wrap-script-literals
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should line wrap string literals that appear in script attributes.Tidy wraps long script string literals by inserting a backslash character before the line break.
See also: wrap-attributes - wrap-sections
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should line wrap text contained within <![ ... ]> section tags.
Character Encoding options:
- ascii-chars
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
Can be used to modify behavior of the clean option when set to yes.If set to yes when using clean, &emdash;, ”, and other named character entities are downgraded to their closest ASCII equivalents.
See also: clean - char-encoding
-
Type: Encoding
Default: utf8
Example: raw, ascii, latin0, latin1, utf8, iso2022, mac, win1252, ibm858, utf16le, utf16be, utf16, big5, shiftjis
This option specifies the character encoding Tidy uses for both the input and output.For ascii Tidy will accept Latin-1 (ISO-8859-1) character values, but will use entities for all characters whose value >127.
For raw, Tidy will output values above 127 without translating them into entities.
For latin1, characters above 255 will be written as entities.
For utf8, Tidy assumes that both input and output are encoded as UTF-8.
You can use iso2022 for files encoded using the ISO-2022 family of encodings e.g. ISO-2022-JP.
For mac and win1252, Tidy will accept vendor specific character values, but will use entities for all characters whose value >127.
For unsupported encodings, use an external utility to convert to and from UTF-8.
See also: input-encoding, output-encoding - input-encoding
-
Type: Encoding
Default: utf8
Example: raw, ascii, latin0, latin1, utf8, iso2022, mac, win1252, ibm858, utf16le, utf16be, utf16, big5, shiftjis
This option specifies the character encoding Tidy uses for the input. See char-encoding for more info.
See also: char-encoding - language
-
Type: String
Default: -
Default: -
Currently not used, but this option specifies the language Tidy would use if it were properly localized. For example: en. - newline
-
Type: enum
Default: Platform dependent
Example: LF, CRLF, CR
The default is appropriate to the current platform.Genrally CRLF on PC-DOS, Windows and OS/2; CR on Classic Mac OS; and LF everywhere else (Linux, Mac OS X, and Unix).
- output-bom
-
Type: AutoBool
Default: auto
Example: auto, y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should write a Unicode Byte Order Mark character (BOM; also known as Zero Width No-Break Space; has value of U+FEFF) to the beginning of the output, and only applies to UTF-8 and UTF-16 output encodings.If set to auto this option causes Tidy to write a BOM to the output only if a BOM was present at the beginning of the input.
A BOM is always written for XML/XHTML output using UTF-16 output encodings.
- output-encoding
-
Type: Encoding
Default: utf8
Example: raw, ascii, latin0, latin1, utf8, iso2022, mac, win1252, ibm858, utf16le, utf16be, utf16, big5, shiftjis
This option specifies the character encoding Tidy uses for the output.Note that this may only be different from input-encoding for Latin encodings (ascii, latin0, latin1, mac, win1252, ibm858).
See char-encoding for more information
See also: char-encoding
Miscellaneous options:
- error-file
-
Type: String
Default: -
Default: -
This option specifies the error file Tidy uses for errors and warnings. Normally errors and warnings are output to stderr.
See also: output-file - force-output
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should produce output even if errors are encountered.Use this option with care; if Tidy reports an error, this means Tidy was not able to (or is not sure how to) fix the error, so the resulting output may not reflect your intention.
- gnu-emacs
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should change the format for reporting errors and warnings to a format that is more easily parsed by GNU Emacs. - gnu-emacs-file
-
Type: String
Default: -
Default: -
Used internally. - keep-time
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should keep the original modification time of files that Tidy modifies in place.Setting the option to yes allows you to tidy files without changing the file modification date, which may be useful with certain tools that use the modification date for things such as automatic server deployment.
Note this feature is not supported on some platforms.
- output-file
-
Type: String
Default: -
Default: -
This option specifies the output file Tidy uses for markup. Normally markup is written to stdout.
See also: error-file - quiet
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should output the summary of the numbers of errors and warnings, or the welcome or informational messages. - slide-style
-
Type: String
Default: -
Default: -
This option has no function and is deprecated. - tidy-mark
-
Type: Boolean
Default: yes
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should add a meta element to the document head to indicate that the document has been tidied.Tidy won't add a meta element if one is already present.
- write-back
-
Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0
This option specifies if Tidy should write back the tidied markup to the same file it read from.You are advised to keep copies of important files before tidying them, as on rare occasions the result may not be what you expect.
SEE ALSO
For more information about HTML Tidy:For more information on HTML:
-
HTML: Edition for Web Authors (the latest HTML specification)
dev.w3.org/html5/spec-author-viewHTML: The Markup Language (an HTML language reference)
dev.w3.org/html5/markup
For bug reports and comments:
Or send questions and comments to public-htacg@w3.org.
Validate your HTML documents using the W3C Nu Markup Validator:
AUTHOR
Tidy was written by Dave Raggett <dsr@w3.org>, and subsequently maintained by a team at tidy.sourceforge.net and now maintained by HTACG (www.htacg.orgThe sources for HTML Tidy are available at github.com/htacg/tidy-html5 under the MIT Licence.