HTML source code

They have: 111 posts

Joined: Jun 2006

Is formatting HTML source code important?

SBalan Group
http://www.sbalanprojects.com/

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

Depends who you ask I suppose. For me, yes! I like to be able to read my code afterwards.

Am also a bit of a purist though. I like to be able to look at my written code and think: "That looks beautiful." But then, I definately go too far with that. Smiling

Make it readable, but don't get anal about it. That's a good rule of thumb.

a Padded Cell our articles site!

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

Formatting is a good habit to get in, as Jeeves said, it is nice to be able to read the code later. Indentation can make things so easy to see. Say you have three nested tables, if you don't do indentation, halfway n the middle it becomes harder to see which table a belongs to.

There are many times people post code samples here and ask for help. On top of not wrappng the code in tage to place it in a fixed font, things just seem thrown together. Ususally first thing I do is cut and paste it into an editor and format it. IMO more poeple would get more help on potings like that if they formatted it more readable.

Now the other hand, there is only one reason to not have formatted code; but you should still have a formatted copy: optimizing code to be a smaller file size (getting rid of all whitespace). For the most part though, I don't see the need to do that much, hardly any site is of size that this would make much difference.

-Greg

He has: 698 posts

Joined: Jul 2005

I always format my code, but I another thing I suggest, which isn't going to matter in this case because you're just talking about HTML, but when I'm doing a lot of heavy PHP/MySQL coding, I'll seperate big chunks of code into two or three files and include them into a file so that I know exactly where the problem is coming from (because I always seem to have a few Sticking out tongue).

But like I said, that doesn't matter in HTML because you won't get error messages. Wink

Kurtis

Busy's picture

He has: 6,151 posts

Joined: May 2001

Comments can also be up there with formatting.
If you have a nested table, list, div's ... a comment can save many hours later

demonhale's picture

He has: 3,278 posts

Joined: May 2005

I do too, like main div and its closed div... just do tabs basically, and yes its very important to put comments especially if your doing a mix of html and php...

They have: 111 posts

Joined: Jun 2006

Hey Smiling , thanks all for your wonderful suggestions.....

SBalan Group
http://www.sbalanprojects.com/

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.