• List 1
  • List 2" /> Document
    • List 1
    • List 2" /> Document
      • List 1
      • List 2"/>
        DEVHIDE
        • Home (current)
        • About
        • Contact
        • Cookie
        • Home (current)
        • About
        • Contact
        • Cookie
        • Disclaimer
        • Privacy
        • TOS
        Login Or Sign up

        Indent <head> and <body> using HTML Tidy

        215 Views Asked by AudioBubble At 02 August 2019 at 23:19 2025-12-20T23:29:16.262530

        I want to indent

        <!DOCTYPE html>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <title>Document</title>
        </head>
        <body>
            <ul>
                <li>List 1</li>
                <li>List 2</li>
                <li>List 3</li>
                <li>List 4</li>
                <li>List 5</li>
            </ul>
        </body>
        </html>
        

        to

        <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta charset="UTF-8">
                <title>Document</title>
            </head>
            <body>
                <ul>
                    <li>List 1</li>
                    <li>List 2</li>
                    <li>List 3</li>
                    <li>List 4</li>
                    <li>List 5</li>
                </ul>
            </body>
        </html>
        

        with tidy -config config.txt -m index.html.

        The config.txt looks like

        doctype: html5
        indent: auto
        indent-spaces: 4
        wrap: 0
        tab-size: 4
        quiet: yes
        show-warnings: no
        tidy-mark: no
        

        The version is: HTML Tidy for Apple macOS version 5.6.0

        I skimmed through HTML Tidy 5.7.0 Options Quick Reference and tried a few things, but without success.

        What is missing?

        html macos command-line htmltidy
        Original Q&A
        1

        There are 1 best solutions below

        0
        stackprotector stackprotector On 07 June 2020 at 16:58

        The "problem" is your option indent: auto. In the man pages, you can read:

        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.
        

        When you set indent to yes, your <head> and <body> sections will be indented, but also all list items, which you might not like:

        <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta charset="UTF-8">
                <title>
                    Document
                </title>
            </head>
            <body>
                <ul>
                    <li>List 1
                    </li>
                    <li>List 2
                    </li>
                    <li>List 3
                    </li>
                    <li>List 4
                    </li>
                    <li>List 5
                    </li>
                </ul>
            </body>
        </html>
        

        FYI: Instead of writing all options for tidy into a config file, you can also pass them as options by prefixing each option with -- and adding the value separated by space. The minimal command to produce the above output is:

        tidy --indent yes --indent-spaces 4 --quiet yes --tidy-mark no index.html
        

        Might be usefull in some cases.

        Related Questions in HTML

        • How to store a date/time in sqlite (or something similar to a date)
        • How to use custom font during html to pdf conversion?
        • Storing the preferred font-size in localStorage
        • mp4 embedded videos within github pages website not loading
        • Scrimba tutorial was working, suddenly stopped even trying the default
        • Is there any way to glow this bulb image like a real light bulb
        • With non-graphical maps in Leaflet, zoomDelta doesn't work
        • What can I do to improve my coding on both html and css
        • Uncaught TypeError: google.maps.LatLng is not a constructor at init (script.js:7:13)
        • Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
        • Displaying a Movie List on a Website Using Jinja2 and Bootstrap
        • How to redirect to thank you page after submitting a Google form embedded into a Google Site?
        • Storing selected language in localStorage
        • Fences (parenthesis, braces) in HTML and MathML
        • Understanding Scroll Anchoring Behavoir

        Related Questions in MACOS

        • Error installing Nativescript on Mac M2 Sonoma 14.4.1
        • macOS - Most secure way of a GUI SUDO_ASKPASS
        • When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
        • Why does Hugo generate different taxonomy-related HTML on different OS's?
        • ZSH function parameters conundrum
        • how to make read only file/directory in Mac writable
        • macOS BigSur - Unable to run bundled php version or brew php 8
        • 9 Digit Addresses in Hexadecimal System in MacOS
        • MacOS Bash-Script: while read p and echo
        • How to make a range for tail rows on a categorized table in Numbers with JXA scripts?
        • Cannot build a basic project with curl on Mac (M2) for Raspberry Pi Pico
        • How to recover deleted files from create vite react project
        • Can't run built SFML project from Xcode template
        • React Native - RealmJS - Linker command failed with exit code 1
        • How can I manually add a keyboard shortcut to a Shortcut Action Service directly via the system files, without going through the System Prefs GUI?

        Related Questions in COMMAND-LINE

        • ZSH function parameters conundrum
        • Parse command line arguments and write useful usage message without additional code
        • Playwright JS: Getting an error when debugging using line numbers
        • NPM Command Line Tool - Command not working
        • How to get argument from Command line for my python package
        • Send a json command to an app at a known port/address?
        • Using command to open Privacy & Security > Proflies page
        • Extract filepaths of .MP4 files in subfolders of main folder to textfile
        • Does Mac OS have different Git versioning?
        • Trouble Fetching Go Modules: Network Timeout When Accessing proxy.golang.org
        • Why does command substitution work in these ways?
        • Finding total RAM consumption of process, including swap
        • When using the ripgrep command in the Terminal how can I search for files which contain one pattern AND another pattern?
        • I can't use command "start" in git bash
        • Executing a Jupyter Notebook from the Command Line with a Specified Kernel

        Related Questions in HTMLTIDY

        • Proper Way to Escape the | Character Using HTML Entities
        • Python exception thrown by libtidy is amusingly impossible to catch
        • `-:55: HTML parser error : htmlParseEntityRef: expecting ';'`: clean up HTML file with xmllint?
        • How to run HTML Tidy so that it fixes the issues in HTML that makes it non-well-formed, not just report issues?
        • Indent <head> and <body> using HTML Tidy
        • DLL not found error after publishing in VS2015 — tidy.x64.dll
        • How to make tidy (libtidy5) format html with inline elements treated as block elements
        • Sublime Linter / htmltidy not working after Mojave update
        • Prevent HTML Tidy from messing meta tags ( schema markup )
        • Can't figure out how to invoke html5Tidy from Python 3
        • xdmp.tidy(html) removes useful Article tags
        • How to run Tidy-html5 (aka HTML Tidy) recursively on all html files?
        • HTML Tidy command-line syntax?
        • HTML tidy output option not working
        • Get indented html using tidyhtml in asp.net using c#

        Trending Questions

        • UIImageView Frame Doesn't Reflect Constraints
        • Is it possible to use adb commands to click on a view by finding its ID?
        • How to create a new web character symbol recognizable by html/javascript?
        • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
        • Heap Gives Page Fault
        • Connect ffmpeg to Visual Studio 2008
        • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
        • How to avoid default initialization of objects in std::vector?
        • second argument of the command line arguments in a format other than char** argv or char* argv[]
        • How to improve efficiency of algorithm which generates next lexicographic permutation?
        • Navigating to the another actvity app getting crash in android
        • How to read the particular message format in android and store in sqlite database?
        • Resetting inventory status after order is cancelled
        • Efficiently compute powers of X in SSE/AVX
        • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

        Popular # Hahtags

        javascript python java c# php android html jquery c++ css ios sql mysql r reactjs

        Popular Questions

        • How do I undo the most recent local commits in Git?
        • How can I remove a specific item from an array in JavaScript?
        • How do I delete a Git branch locally and remotely?
        • Find all files containing a specific text (string) on Linux?
        • How do I revert a Git repository to a previous commit?
        • How do I create an HTML button that acts like a link?
        • How do I check out a remote Git branch?
        • How do I force "git pull" to overwrite local files?
        • How do I list all files of a directory?
        • How to check whether a string contains a substring in JavaScript?
        • How do I redirect to another webpage?
        • How can I iterate over rows in a Pandas DataFrame?
        • How do I convert a String to an int in Java?
        • Does Python have a string 'contains' substring method?
        • How do I check if a string contains a specific word?
        .

        Copyright © 2021 Jogjafile Inc.

        • Disclaimer
        • Privacy
        • TOS
        • Homegardensmart
        • Math
        • Aftereffectstemplates