Is it a sin that I have used this much indentations, spaces and comments in my source codes?

uhuru
avatar
rank Regular

Regular


Posts: 38
Joined: 2007-04-16

Is it a sin that I have used this much indentations, spaces and comments in my source codes for both the html and CSS part?

http://virtualseafarer.com/witch/ndiswrapper/index.html#
http://virtualseafarer.com/witch/ndiswrapper/css/ndis_00.css
http://virtualseafarer.com/witch/ndiswrapper/css/tutorial_base.css

Chris..S
Chris..S's picture
rank Moderator

Moderator


Posts: 5624
Joined: 2005-02-22

Not at all. Personally, I

Not at all. Personally, I think you've gone overboard with your multi-line section comments in the HTML, but the idea is fine. Indentation and comments make page maintenance much (much much ... much) easier. For me, the longer you do this and the more you have to alter work you've done previously (or that others have done), the more you will start organising your code so its clear what is happening where.

For me, in html I try to manage indenting so each nested element is indented a similar amount. When closing a major page element, I'll add a comment to say what that element is (e.g. </div><!-- #sidebar -->). In CSS, I will use whole line comments to break the CSS up into sections and explain what each section is.

uhuru
uhuru's picture
rank Regular

Regular


Posts: 38
Joined: 2007-04-16

Chris..S wrote:Not at all.

Chris..S wrote:
Not at all. Personally, I think you've gone overboard with your multi-line section comments in the HTML, but the idea is fine. Indentation and comments make page maintenance much (much much ... much) easier.

My middle name is Overboard Sticking out tongue Capitan Overboard.

isedeasy
isedeasy's picture
rank Enthusiast

Enthusiast


Posts: 63
Joined: 2008-02-09
Location: Bristol

Looks good to me, I really

Looks good to me, I really hate it when I have to look/edit other people code and its all on a couple lines Scared

I tend to code like this...

<body>

   <div id="wrapper">

      <h1>blah</h1>

      <p>blah blah</p>

   </div> <!-- END WRAPPER -->

</body>

#wrapper {
width:960px;
margin:0 auto;
}

I think the key is to find a style you like and stick to it Eye-wink

p.s I also think the multi-line comments are overboard Sticking out tongue

edit - Also I can only see as far down as your 8th menu item and my screen is not tiny...

"If a man is trying to hang himself from the tree in my yard but the knot keeps slipping and allowing him to fall before it kills him do you expect someone to go out and teach him to tie a better knot?" - Triumph

purewebdesigner
purewebdesigner's picture
rank Enthusiast

Enthusiast


Posts: 90
Joined: 2007-04-22
Location: USA

I think it looks clean, to

I think it looks clean, to each their own, so long as you are the main person making edits and updates. I do tend to keep mine organized thought by indenting each nested element with the divs.

gary.turner
gary.turner's picture
rank Moderator

Moderator


Posts: 5698
Joined: 2004-06-25
Location: Dallas

Like the others, I think

Like the others, I think you're on the right path. I'd like to see you tweak a couple of things.

  1. Maintain your formatting plan throughout. You indent some things and not others. My own plan is to indent nested elements, and add a linefeed between sibling elements.
  2. Tabs do not have an explicit value. In Firefox's source viewer, for example, tabs are eight spaces. That is an insane value. At eight spaces, just a few levels deep, and you're half way across the page. (A bug has been filed to make the value configurable, but I think it's not a high priority.) Set your editor to convert tabs to spaces on saving. Then, no matter what viewer/editor is used, the indentions are as you meant them to be. I have Emacs set to do so, as is HTMLTidy. I set the tab value to two spaces. You may prefer three or four.
  3. In the css, treat the rulesets as a nested element. Indent 2–4 spaces. You want clear definition, but not so much visual separation.
  4. It is a good idea, but not one I'm fanatical about, to put the rulesets within each selector in alphabetical order. You'll be amazed at the number of times you'll catch yourself trying to repeat a rule.
  5. Organize your selectors top-down; global elements, global classes and sections (id) with their elements and classes.

For examples, see the source at gtwebdev and the css.

Not everyone agrees with these formatting rules, but what do they know? Laughing out loud

cheers,

gary

A pianist who has learned the wrong system of fingering cannot become a virtuoso until he has laboriously taught himself the proper method.

My site is slo-o-owly being reconstructed; visit anyway.

uhuru
uhuru's picture
rank Regular

Regular


Posts: 38
Joined: 2007-04-16

Holy cow that's a lot to

Holy cow that's a lot to think about, I'll try to assimilate as time goes on. Tnx for the tips!