Score Boss Blue Salomon 3 Blue Tea Water Shoe Green Women's Techamphibian 7OZwq1f Score Boss Blue Salomon 3 Blue Tea Water Shoe Green Women's Techamphibian 7OZwq1f Score Boss Blue Salomon 3 Blue Tea Water Shoe Green Women's Techamphibian 7OZwq1f Score Boss Blue Salomon 3 Blue Tea Water Shoe Green Women's Techamphibian 7OZwq1f Score Boss Blue Salomon 3 Blue Tea Water Shoe Green Women's Techamphibian 7OZwq1f Score Boss Blue Salomon 3 Blue Tea Water Shoe Green Women's Techamphibian 7OZwq1f

Why indent your code? Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7

Let's look at some examples of coding techniques to make it clear why you should indent your HTML.

Wrong method 1: Everything on one line Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.p>

Problems:

  • Hard to figure out where code ends & text/content begins
  • Hard to see where the

    is, even with wrapping turned on

Wrong method 2: 3 lines, but no indentation Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7Pink Ariat Terrain Hiking Timber True Boot Women's Multi nxqvCB

<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation 
ullamco laboris nisi ut aliquip ex ea commodo consequat.
p>

OR

<p> 
<Green Score Women's Water Shoe Tea Techamphibian Salomon 3 Boss Blue Blue a href="http://en.wikipedia.org/wiki/H._P._Lovecraft">H. P. Lovecrafta> 
p>

Problem: Because everything is at left margin, hard to differentiate code & text/content

Best method: indent text/content Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7

<p> 
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
    incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
    exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Score Salomon Techamphibian Boss Shoe Green 3 Water Tea Women's Blue Blue p>

Advantages:

  • Start (

    ) & end (

    ) are at same level, so it's easy to see that you've closed code & also see where code starts & ends
  • Easy to differentiate between code & text/content

Examples of code indentation Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7

Here are some examples of how WebSanity likes to indent our code.

Block-level elements Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7

<p> 
    Lorem ipsum. 
p>
<p> 
    Lorem ipsum 
    <br>Dolor sit amet 
p>
<blockquote> 
    <p> 
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
        ut labore et dolore magna aliqua. 
    p> 
blockquote>

Note: Notice how text/content is indented inside

, and then

is indented inside Score Water Shoe Tea Blue Salomon 3 Blue Women's Techamphibian Boss Green

. This is called nesting. See how easy it is to tell what's a child of what?

<table> 
    <tr> 
        <td> 
            Lorem ipsum dolor sit amet 
        td> 
        <td> 
            Consectetur adipisicing 
        td> 
    tr> 
    <tr> 
        <td> 
            Lorem ipsum dolor sit amet 
        Score Salomon 3 Techamphibian Green Blue Water Shoe Blue Boss Tea Women's Water Blue Boss Green Blue 3 Tea Salomon Shoe Techamphibian Score Women's td> 
        <Salomon Techamphibian Boss Shoe 3 Women's Water Green Tea Blue Blue Score td> 
            Consectetur adipisicing 
        td> 
    tr> 
table>

Note: Again with the multiple levels of indenting—but it should be obvious how much it helps reading that code!

Exceptions Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7

<h1>Title of the pageh1>

Note: We don't indent

& other headers because they're short, but if you want to indent , that would be fine.

<head><title>Document titletitle>
head>

Note: Again, we don't indent </code> & most other items inside <head> because they're short. </p> </blockquote> <pre><code class="html hljs "><span class="hljs-tag"><<span class="hljs-title">ul</span>></span> <span class="hljs-tag"><<span class="hljs-title">li</span>></span>Lorem<span class="hljs-tag"></<span class="hljs-title">li</span>></span> <span class="hljs-tag"><<span class="hljs-title">li</span>></span>Ipsum<span class="hljs-tag"></<span class="hljs-title">li</span>></span> <span class="hljs-tag"><<span class="hljs-title">li</span>></span>Dolor<span class="hljs-tag"></<span class="hljs-title">li</span>></span> <span class="hljs-tag"></<span class="hljs-title">ul</span>></span></code></pre> <blockquote> <p> Note: We don't indent <code><li></code> because most of the time the contents are short, because we're more concerned about the <code><ul></code> & <code></ul></code>, & because it can really lengthen the overall code. That said, if you want to indent <code><li></code>, feel free. </p> </blockquote> <h2 id="inline-examples"> Inline elements <a href="http://www.laowhining.com/Nbpu_Side_Ankle_Peep_Cambridge_Blush_Chunky_Wedge_Bootie_Cutout_Women's_Platform_Toe_Select_qTWzIw7-oveev/13.html" title="Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7">Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7</a></h2> <p> You never indent inline elements. Treat them like text/content. Examples: </p> <pre><code class="html hljs "><span class="hljs-tag"><<span class="hljs-title">p</span>></span> Lorem ipsum <span class="hljs-tag"><<span class="hljs-title">strong</span>></span>dolor sit amet<span class="hljs-tag"></<span class="hljs-title"><big>Shoe Salomon 3 Tea Techamphibian Boss Blue Blue Water Green Score Women's</big> strong</span>></span>, consectetur adipisicing elit, sed do <span class="hljs-tag"><<span class="hljs-title">em</span>></span>eiusmod tempor<span class="hljs-tag"></<span class="hljs-title">em</span>></span> incididunt ut labore et <span class="hljs-tag"><<span class="hljs-title">code</span>></span>dolore magna aliqua<span class="hljs-tag"></<span class="hljs-title">code</span>></span>. Ut enim ad minim veniam, <span class="hljs-tag"><<span class="hljs-title">font</span> <span class="hljs-attribute">size</span>=<span class="hljs-value">"5"</span>></span>quis nostrud<span class="hljs-tag"></<span class="hljs-title">font</span>></span> exercitation ullamco <span class="hljs-tag"><<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">"http://www.demonoid.me"</span>></span>laboris nisi ut aliquip<span class="hljs-tag"></<span class="hljs-title">a</span>></span> ex ea commodo consequat. <span class="hljs-tag"></<span class="hljs-title">p</span>></span></code></pre> <pre><code class="html hljs "><span class="hljs-tag"><<span class="hljs-title"><strong>Water Blue Salomon Techamphibian Women's Tea Blue Green Shoe Boss 3 Score</strong> blockquote</span>></span> <span class="hljs-tag"><<span class="hljs-title">p</span>></span> Lorem ipsum dolor sit amet, <span class="hljs-tag"><<span class="hljs-title">a</span> <span class="hljs-attribute">href</span>=<span class="hljs-value">"http://www.avclub.com"</span>></span>consectetur adipisicing elit<span class="hljs-tag"></<span class="hljs-title">a</span><a href="http://laowhining.com/Lace_Two_Piece_Elegant_Floral_Jumpsuit_White_Black_Black_xwFAq6F-fifer/12.html" title="Lace Two Piece Elegant Floral Jumpsuit White Black Black xwFAq6F">Lace Two Piece Elegant Floral Jumpsuit White Black Black xwFAq6F</a>></span>, sed do <span class="hljs-tag"><<span class="hljs-title">strong</span>></span>eiusmod tempor<span class="hljs-tag"></<span class="hljs-title">strong</span>></span> incididunt ut labore et <span class="hljs-tag"><<span class="hljs-title">em</span>></span>dolore<span class="hljs-tag"></<span class="hljs-title">em</span>></span> magna aliqua. <span class="hljs-tag"></<span class="hljs-title">p</span>></span> <span class="hljs-tag"></<span class="hljs-title">blockquote</span>></span></code></pre> <h2 id="what-about-the-basic-structure"> What about the basic structure of a webpage? <a href="http://www.laowhining.com/Nbpu_Side_Ankle_Peep_Cambridge_Blush_Chunky_Wedge_Bootie_Cutout_Women's_Platform_Toe_Select_qTWzIw7-oveev/13.html" title="Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7">Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7</a></h2> <p> Look at the following code. You'd think that <code><head></code> & <code><big>Tea Boss Green Techamphibian 3 Blue Shoe Women's Blue Score Salomon Water</big> <body></code> would be indented inside <code><html></code>—after all, they're children of <code><head></code>, so shouldn't they be indented? </p> <pre><code class="html hljs "><span class="hljs-tag"><<span class="hljs-title">html</span>></span> <span class="hljs-tag"><<span class="hljs-title">head</span>></span> <span class="hljs-tag"><<span class="hljs-title">title</span>></span>Document title<span class="hljs-tag"></<span class="hljs-title">title</span>></span> <span class="hljs-tag"></<span class="hljs-title">head</span>></span> <span class="hljs-tag"><<span class="hljs-title"><strong>Tea 3 Salomon Women's Boss Blue Blue Water Green Score Techamphibian Shoe</strong> body</span>></span> <span class="hljs-tag"><<span class="hljs-title">h1</span>></span>Page title<span class="hljs-tag"></<span class="hljs-title">h1</span>></span> <span class="hljs-tag"><<span class="hljs-title">p</span>></span> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt <span class="hljs-tag"></<span class="hljs-title">p</span>></span> <span class="hljs-tag"></<span class="hljs-title">body</span>></span> <span class="hljs-tag"></<span class="hljs-title">html</span>></span></code></pre> <p> So why aren't <code><head></code> & <code><body></code> indented? A couple of reasons: </p> <ul> <li>You know that <code><head></code> & <code><body></code> are the children of <code><html></code>; in fact, they're <em>always</em> the <em>only</em> children of <code><html></code>, so there's no need to remind yourself of this via nesting</li> <li>You save yourself one level on indentation; when you start nesting HTML inside HTML inside HTML inside HTML, this can add up</li> </ul> </div> <h2 id="your-text-editor">Your text editor should make it easy to indent your code<a href="http://www.laowhining.com/Nbpu_Side_Ankle_Peep_Cambridge_Blush_Chunky_Wedge_Bootie_Cutout_Women's_Platform_Toe_Select_qTWzIw7-oveev/13.html" title="Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7">Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7</a></h2><a href="http://laowhining.com/Padded_Cherry_Dr_Women's_Maelly_Red_Collar_Martens_Boot_w7xY7rtq-fnfat/1.html" title="Padded Cherry Dr Women's Maelly Red Collar Martens Boot w7xY7rtq">Padded Cherry Dr Women's Maelly Red Collar Martens Boot w7xY7rtq</a> <p>You could press tab or the space bar every single time you want to indent your code, but you shouldn't have to do that. Fortunately, good text editors help you out when it comes to indenting.</p> <h3 id="auto-indent">Auto-indent<a href="http://www.laowhining.com/Nbpu_Side_Ankle_Peep_Cambridge_Blush_Chunky_Wedge_Bootie_Cutout_Women's_Platform_Toe_Select_qTWzIw7-oveev/13.html" title="Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7">Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7</a></h3> <p>BBEdit, for instance, has a setting in its Preferences for "Auto-indent", which it defines as follows: "When this option is selected, pressing the Return key in new windows automatically inserts spaces or tabs to indent the new line to the same level as the previous line."</p> <p>Any good text editor should have a setting like this somewhere. The trick is finding it in the editor's Preferences or Options.</p> <h3 id="spaces-or-tabs-spaces">Spaces or tabs? (Spaces!)<a href="http://www.laowhining.com/Nbpu_Side_Ankle_Peep_Cambridge_Blush_Chunky_Wedge_Bootie_Cutout_Women's_Platform_Toe_Select_qTWzIw7-oveev/13.html" title="Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7">Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7</a></h3> <p>Should you use spaces or tabs for indenting? A debate has raged on this topic for decades, with different developers insisting that theirs is the right choice. WebSanity uses spaces, for various reasons, so that is the right choice, clearly.</p> <p>Your text editor should let you choose what gets inserted when you press the TAB key: a tab or spaces. Different text editors call that setting different things. Here are a few examples:</p> <ul> <li><strong>BBEdit</strong>: Preferences > Editor Defaults > Auto-expand tabs</li> <li><strong>Komodo Edit</strong>: Options/Preferences > Editor > Indentation > Prefer Tab characters over spaces</li> <li><strong>Notepad++</strong>: Preferences > Language Menu/Tab Settings > Replace by space</li> </ul> <p class="note">Note: If anyone knows of any others that I should add, let me know.</p><a href="http://laowhining.com/Naturalizer_Chrome_Toe_Womens_Pointed_Bengol_Flats_Slide_BwSpB-tmtst/10.html" title="Naturalizer Chrome Toe Womens Pointed Bengol Flats Slide BwSpB">Naturalizer Chrome Toe Womens Pointed Bengol Flats Slide BwSpB</a> <h3 id="how-many-spaces">How many spaces?<a href="http://www.laowhining.com/Nbpu_Side_Ankle_Peep_Cambridge_Blush_Chunky_Wedge_Bootie_Cutout_Women's_Platform_Toe_Select_qTWzIw7-oveev/13.html" title="Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7">Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7</a></h3> <p>The next question is, how many spaces get inserted when you press TAB? Basically, people either choose 2, 4, or 8 spaces. In WebSanity's opinion, 8 is far too many, 4 is acceptable but a bit too large, & 2 is just right. With 2, you can see the indentation, but lots of nesting doesn't push your code out to ridiculous lengths, as you can see in the following:</p> <p>Your text editor should let you choose how many spaces get inserted when you press TAB. Different text editors set that in different ways. Here are some examples:</p> <ul> <li><strong>BBEdit</strong>: Preferences > Editor Defaults > Tab width</li> <li><strong>Komodo Edit</strong>: Options/Preferences > Editor > Indentation > Number of spaces per indent</li> <li><strong>Notepad++</strong>: Preferences > Language Menu/Tab Settings > Tab size</li> </ul> <p class="note">Note: Again, if anyone knows of any others that I should add, let me know.</p> <h3 id="indenting-several-lines-at-once">Indenting several lines at once<a href="http://www.laowhining.com/Nbpu_Side_Ankle_Peep_Cambridge_Blush_Chunky_Wedge_Bootie_Cutout_Women's_Platform_Toe_Select_qTWzIw7-oveev/13.html" title="Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7">Nbpu Side Ankle Peep Cambridge Blush Chunky Wedge Bootie Cutout Women's Platform Toe Select qTWzIw7</a></h3> <p>What if you want to indent more than one line of code? Like 5? Or 25? You could manually move the cursor to the start of each line and press TAB the requisite number of times, but that would quickly grow tedious.</p> <p>Fortunately, every good text editor lets you select all the lines you wish to indent and then indent them all as a group. This is a fantastic time saver!</p> <p>Here's how various text editors enable you to indent lines at a group:</p> <ul> <li><strong>BBEdit</strong>: Highlight the lines & press TAB. To backdent the lines, press Shift-TAB.</li> <li><strong>Komodo Edit</strong>: Highlight the lines & press TAB. To backdent the lines, press Shift-TAB.</li> <li><strong>Notepad++</strong>: Highlight the lines & press TAB. To backdent the lines, press Shift-TAB.</li> </ul> </main> </div> <footer> <div class="container"> <div class="row"> <div class="col-sm-4"> <div id="HTMLBlock3787" class="HTMLBlock"> <div class="footer-col-1"> <h3>Contact</h3> <div id="home" class="vcard"> <table> <tbody> <tr> <td class="f">Email</td> <td class="v"><a class="email" href="mailto:scott@granneman.com">scott@granneman.com</a></td> </tr> <tr class="tel"> <td class="f type">Voice</td> <td class="v value"><a href="tel:1-314-780-0489">314-780-0489</a></td> </tr> <tr> <td class="f">Address</td> <td class="v"> <div class="adr"> <div class="street-address"> 39 Summit Place </div> <span class="locality">St. Louis</span>, <span class="region">MO</span> <span class="postal-code"><em>Green Water Salomon Tea Blue Blue Boss Shoe Techamphibian 3 Score Women's</em> 63119</span><a href="http://laowhining.com/Dearfoams_Women's_Clog_Chenille_Slipper_Black_6PFgq-xkzu/6.html" title="Dearfoams Women's Clog Chenille Slipper Black 6PFgq">Dearfoams Women's Clog Chenille Slipper Black 6PFgq</a> <div class="country-name"> United States </div> </div> </td> </tr> </tbody> </table> </div> <h3>Work</h3> <p> For work info, see <a href="/com">WebSanity</a>. </p> </div> </div> </div> <div class="col-sm-4"> <div id="HTMLBlock2299" class="HTMLBlock"> <p>All content, unless <a href="/presentations/creative-commons-license/">under a Creative Commons license,</a> is © 1997-2018 Scott Granneman.</p> <p>(Take a look around—a lot of content is licensed <a href="/presentations/creative-commons-license/">under a Creative Commons license,</a> which gives YOU a lot of freedom to reuse my work.)</p> </div> </div> <div class="col-sm-4"> <div id="HTMLBlock3788" class="HTMLBlock"> <ul class="list-unstyled social-media-icons"> <li><a href="/scottgranneman"><i class="fa fa-facebook-official"></i></a></li> <li><a href="/scottgranneman"><i class="fa fa-twitter"><strong>3 Techamphibian Boss Blue Green Score Salomon Women's Blue Shoe Water Tea</strong> </i></a></li> <li><a href="/profile"><i class="fa fa-linkedin"></i></a></li> <li><a href="http://www.laowhining.com/Hill_Mountain_45200_6"_Explorer_Boots_Sole_Side_Vibram_Hiking_GTX_USA_Waterproof_Outdoor_and_Leather_Traction_Combat_Gore_Made_Braking_Boot_Brown_Downhill_Danner_Women's_In_TEX_Boot_5qTwnWECzg-difcf/17.html" title="Hill Mountain 45200 6" Explorer Boots Sole Side Vibram Hiking GTX USA Waterproof Outdoor and Leather Traction Combat Gore Made Braking Boot Brown Downhill Danner Women's In TEX Boot 5qTwnWECzg">Hill Mountain 45200 6" Explorer Boots Sole Side Vibram Hiking GTX USA Waterproof Outdoor and Leather Traction Combat Gore Made Braking Boot Brown Downhill Danner Women's In TEX Boot 5qTwnWECzg</a></li> <li><a href="/user"><i class="fa fa-youtube-play"></i></a></li> <li><a href="/user"><i class="fa fa-lastfm"></i><a href="http://laowhining.com/Women's_Hades_Steampunk_Brown_Shoe_Oxford_Icon_0qqdYwS-cuvp/17.html" title="Women's Hades Steampunk Brown Shoe Oxford Icon 0qqdYwS">Women's Hades Steampunk Brown Shoe Oxford Icon 0qqdYwS</a></a></li> </ul> </div> </div> </div> </div> </footer> <a href="http://www.laowhining.com/Red_White_Striped_Spinnaker_Women's_Oxford_Sebago_Uwnq7tx-exmi/14.html" title="Red White Striped Spinnaker Women's Oxford Sebago Uwnq7tx">Red White Striped Spinnaker Women's Oxford Sebago Uwnq7tx</a> <div> <ul> <li><span>Synthetic</span></li> <li><span>Imported</span></li> <li><span>Rubber sole</span></li> <li><span>Shaft measures approximately low-top from arch</span></li> <li><span>Mesh construction moves seamlessly from dry to wet conditions, a sipped outsole ensures grip on wet rocks and surfaces, even under water. </span></li> <li><span>Cabriolet design for easy on, easy off.  </span></li> <li><span>Sensifit wraps evenly around the foot, and Quicklace provides fast adjustment on the fly, while a heel strap comfortably locks the back of the foot in place.    </span></li> </ul> </div> <div> <embed src="http://www.youtube.com/v/r2727r9Tox9?version=3&autohide=1" /> </div> </body> </html>