How do I format a messy html code?

Here is a messy code …

I find select box and options are in single line. …no proper indention.

Is there any tool which could properly indent and beautify my html code ?

Looking for a lightweight tool. I’ll be dealing with mostly HTML code.

HTML Tidy not only properly indent and beautify your HTML codes, it is also a tool for checking and cleaning up HTML source files as well.

Excellent. This works. you are very much helpful.

I dont want any extra code by html tidy. What. Settings i need to check?

@windowsxp

Take a look at this Firefox Addon - the user interface is very intuitive and simple:

http://users.skynet.be/mgueury/mozilla/

This window pops up when the bottom right hand icon is clicked:


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title>ample code</title>
    <style type='text/css'>
/*<![CDATA[*/
    .bg1 {background-color:#f99} .bg2 {background-color:#9f9} .bg3 {background-color:#99f}
    body {background-color:#eee}
    table {width:88%; margin:1em auto; background-color:#fff}
    /*]]>*/
    </style>
    <style type="text/css">
/*<![CDATA[*/
    div.c2 {WIDTH: 100%; DISPLAY: none}
    div.c1 {DISPLAY: block}
    /*]]>*/
    </style>
  </head>
  <body>
    <table border="3" cellspacing="0" cellpadding="0">
      <tbody>
        <tr>
          <td width="12%">
            Fund Source
          </td>
          <td width="28%">
            <select id="fundSourceId" class="text_box" name="fundRelease.fundSourceId">
              <option selected="selected" value="">
                All
              </option>
              <option value="1">
                National
              </option>
              <option value="2">
                Revolving
              </option>
              <option value="34">
                Perf
              </option>
              <option value="42">
                FundSource18956
              </option>
              <option value="43">
                FundSource50839
              </option>
              <option value="44">
                FundSource96841
              </option>
              <option value="45">
                FundSource2871
              </option>
              <option value="47">
                Treasury Funds
              </option>
              <option value="48">
                livelihood Development
              </option>
              <option value="49">
                livelihood Development english6
              </option>
              <option value="50">
                uu8uhuhuhuhu
              </option>
              <option value="51">
                livelihood Development english6
              </option>
              <option value="52">
                livelihood Development english6
              </option>
              <option value="53">
                Reg Fund1
              </option>
              <option value="54">
                RegFund2
              </option>
              <option value="55">
                ABC
              </option>
              <option value="56">
                Test_2nd_April_National
              </option>
              <option value="57">
                Test_2nd_April_Revolving
              </option>
            </select>
          </td>
          <td width="5%">
            &nbsp;
          </td>
          <td width="12%">
            Start Date*
          </td>
          <td width="43%">
            <input id="startDate" class="text_box_medium hasDatepicker" readonly="readonly" maxlength="50" type="text" name="fundRelease.startDate" jquery1334307120124="148" />
          </td>
        </tr>
        <tr>
          <td>
            &nbsp;
          </td>
        </tr>
        <tr>
          <td width="12%">
            District*
          </td>
          <td>
            <select id="selectedDistrict" class="text_box" onchange="checkBoxFunc();" name="fundRelease.distId" jquery1334307120124="151">
              <option value="">
                Select
              </option>
              <option value="25">
                Dist1
              </option>
              <option value="26">
                Dist2
              </option>
              <option value="27">
                Dist3
              </option>
            </select>
          </td>
          <td>
            <div class="c1" id="div_CheckBox">
              <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tbody>
                  <tr>
                    <td>
                      Divisional Secretariat
                    </td>
                    <td>
                      <input id="checkbox1" align="left" type="checkbox" name="checkbox1" jquery1334307120124="150" />
                    </td>
                  </tr>
                </tbody>
              </table>
            </div>
          </td>
          <td width="12%">
            End Date*
          </td>
          <td width="43%">
            <input id="endDate" class="text_box_medium hasDatepicker" readonly="readonly" maxlength="50" type="text" name="fundRelease.endDate" jquery1334307120124="149" />
          </td>
        </tr>
        <tr>
          <td>
            &nbsp;
          </td>
        </tr>
        <tr>
          <td width="12%">
            <div class="div_division c2" jquery1334307120124="154">
              Division*
            </div>
          </td>
          <td width="28%">
            <div class="div_division c2" jquery1334307120124="155">
              <select id="selectedDivision" class="text_box" name="fundRelease.divId">
                <option selected="selected" value="-1">
                  --- Select ---
                </option>
                <option selected="selected" value="div1">
                  DIV1
                </option>
                <option selected="selected" value="div2">
                  DIV2
                </option>
                <option selected="selected" value="div3">
                  DIV3
                </option>
              </select>
            </div>
          </td>
        </tr>
        <tr>
          <td colspan="5">
            <input id="submit_1682155201" class="submit_btn_base" title="Search" value="Search" type="submit" jquery1334307120124="152" />
          </td>
        </tr>
        <tr>
          <td>
            4.6          </td>
          <td>
            4.1142857142857          </td>
          <td>
            322          </td>
          <td>
            34          </td>
          <td>
            34          </td>
        </tr>
        <tr>
          <td valign="top" colspan="5">
            <div id="searchFundRelease" jquery1334307120124="153">
              &nbsp;
            </div>
          </td>
        </tr>
      </tbody>
    </table>
  </body>
</html>

Click on Advanced (underneath the Tidy! submit button) and uncheck those settings that you do not want.

I installed the addon and it works but the original source code is not shown. I did not play with long enough to find out all the options since I uninstalled it after seeing that it somehow changed a setting on my FileZilla. So be warned before installing.

@tom8,

http://users.skynet.be/mgueury/mozilla/

I installed the addon and it works but the original source code is not shown. I did not play with long enough to find out all the options since I uninst

Try it again when you have more time to find the Filezilla conflict. I have been using the validator for a couple of years and als use FileZilla and have experienced no problems or conflicts.

The following link is to the forum where you could maybe ask for help:

http://htmlpedia.org/phpBB/