• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

HTML Code Spacing

bluestrobe

Platinum Member
My web site has been added onto and modified several times in its existence. Right now in the source, I have all types of spacing and code placement going from one continuous line to several blank lines between the content and the last </div> tag. You get the idea.

I basically just want to clean it up so if someone views the source, they don't cringe or get a headache looking for a particular item.
 
As with everything it's personal preference, different people find different styles easier to understand so just fix it up for yourself.
 
If you use notepad, you can press tab after each tag. And backspace to where the closing tags are in the same column as the opening tag.
 
It's all personal preference, As long as you can read it easily and indentation and line spacing is consistent, that's all that matters.
 
I use single tabs for all my spacing.

<div id="wraper">
tab <div id="content">
tab tab <p>This is a line of text.</p>
tab </div>
</div>
 
i'm a tab indent kinda guy myself...but the coding standards where i work demand that code is indented with 4 spaces instead of tabs

most editors have a setting to make the switch easy (so tab button auto inserts 4 spaces, and a single backspace will delete 4 spaces)
 
Originally posted by: Alone
I use single tabs for all my spacing.

<div id="wraper">
tab <div id="content">
tab tab <p>This is a line of text.</p>
tab </div>
</div>

Same.
 
A quick way to clean it up is with Dreamweaver. It has a format code function, which does a decent (read not perfect) job of making the code readable. If you have a lot of code to clean up, it can get pretty tedious, and DW can save you quite a bit of time.
 
Originally posted by: GundamSonicZeroX
Originally posted by: Evadman
Originally posted by: Alone
I use single tabs for all my spacing.

<div id="wraper">
tab <div id="content">
tab tab <p>This is a line of text.</p>
tab </div>
</div>

Same.

That's the way to do it.
ViM agrees. (Command sequence "{Esc}1G=G" does auto-indent of a whole file.) Who am I to disagree? 🙂
 
Right now I leave my div tags without any spacing and all the content and their tags (<p>, <h5> ect). are one tab over. My "wrapper" tags are in a seperate file so I'm not even going to mess trying to line them up properly in the big picture. I might play with the dreamweaver option tonight.
 
You must not have run into the problem where your layout is all skewed and you spend hours figuring out why, only to realize you've got an extra div tag. With them all aligned properly, I can easily find the opening and closing tags to make sure they're all as they should be.
 
Back
Top