homepage Welcome to WebmasterWorld Guest from 54.196.24.103
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
Forum Library, Charter, Moderator: open

WYSIWYG and Text Code Editors Forum

    
Code Formatting
How do you format your code?
pageoneresults




msg:937590
 2:34 am on Dec 28, 2002 (gmt 0)

I've put a lot of time into researching and formatting html. I see very few who use the style that I've adapted over the years.

Currently, I format my html so there are no breaks in tags. I remove all indents and spaces between tags. What I end up with is code where each tag occupies one line in my html in most instances. If there are soft returns or what is referred to as the <br> tag, then my line of code breaks there and starts on the next line.

Some say they prefer indented html as it is easier to navigate. I'm going to assume that it is all a matter of how you learned and what works best for you.

I will share some valuable observations. Since reformatting all of my clients code and building new sites using my method of formatting, I've seen an overall increase in the ability to secure and obtain pageoneresults.

How do you format your code? Why do you format that way? The reason I posted in this forum is because I'm an FP junkie. Hiss and boo all you want, but I know all the little secrets of the program! ;)

P.S. Validation is a must for me as it has now become second nature when developing sites. Yes, FP is capable of producing valid html in the right hands.

 

jdMorgan




msg:937591
 3:35 am on Dec 28, 2002 (gmt 0)

pageoneresults,

I write code using an indented style - especially when the if-then-elses get nested ten deep. Indentation makes the code structure visually clearer, and aids in finding problems. If I'm hand-coding HTML, I may or may not indent the code; I mostly use indentation for scripting and programming languages, but may revert to it for "tricky" tables or complex layouts in HTML.

Publishing to the web, however, is an altogether different matter; Once the code is debugged and tested thoroughly, then every single unnecessary character is mercilessly eliminated (I use an automated tool to do this). This regulary results in files 10% to 25% smaller than before, and that means faster page loads, fewer bills for bandwidth overages, and less stress on the server.

Jim

choster




msg:937592
 3:41 am on Dec 28, 2002 (gmt 0)

I use a "limited indent" style. Blocks are separated by carriage returns, but are only indented to represent nesting of block-level elements. Inline tags always fall inline.

This I believe to be a good compromise, allowing for readability without adding excessive weight ("white matter?") to documents (for HTML e-mail, we strip out all carriage returns, tabs, and non-content spaces after the final draft is approved).

andreasfriedrich




msg:937593
 9:11 am on Dec 30, 2002 (gmt 0)

Since reformatting all of my clients code and building new sites using my method of formatting, I've seen an overall increase in the ability to secure and obtain pageoneresults.

That would really be surprising. I do understand why SEs might favour valid HTML over invalid HTML. But I cannot think of any reason why they would prefer one code formatting style over another since the HTML spec clearly states that whitespace does not matter.

Could you explain in more details how you measured that increase?

Andreas

pageoneresults




msg:937594
 9:19 am on Dec 30, 2002 (gmt 0)

Content positioning through the use of css. I've stripped all the tables and have absolutely positioned my divs in a particular order.

SmallTime




msg:937595
 9:53 am on Dec 30, 2002 (gmt 0)

I am with pageonresults, perhaps a little looser, but I like to keep it compact without loosing too much readability. A big monitor helps for those long lines. I read somewhere that browsers will take up to a 255 character line in one gulp, longer lines speed rendering. Not sure if that is true, but makes more sense then waltzing through the table tags (I hate it when I see a line with just one tr tag).

andreasfriedrich




msg:937596
 9:54 am on Dec 30, 2002 (gmt 0)

Ok, that I can understand :). I thought code formatting was only about breaking up your code into different lines and indenting those lines, i.e. about the use of whitespace.

Andreas

brotherhood of LAN




msg:937597
 10:38 am on Dec 30, 2002 (gmt 0)

=> Click on "template" :)
-includes DOCTYPE,<title>,<meta description>,<generic style sheet reference> all on seperate lines

2 hard returns after <head>

<divs> seperated by 2 hard returns
<p>'s and </p>'s in same line and sandwiched immediated after <div>

I hardly ever use tabs and just use line breaks to seperate the "chunks", mainly <head> and <body> and seperate <divs>

I've found PHP great to alter "foreign" information to a more friendly code layout. It's handy for simple things like stripping out another webmasters code formatting "preference" and re-arrange it to your liking.

If all info came pre-formatted and in the correct format, how much easier would it be! :)

creative craig




msg:937598
 10:47 am on Dec 30, 2002 (gmt 0)

I tend to keep it all in one block as well, except for header info and one line break in between tables or div's.

Craig

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved