This is also why I prefer two spaces to four for indentations, in any language.
I do as well, except I'm finding that in Javascript, I can't see two spaces well enough. When there's an if statement starting, I've found I need or 4 spaces for the "stuff happening" inside to be obviously indented compared to the word "if". I dunno why. But I also don't use a tab for spacing. Mostly because in gEdit, if I change the tab spacing, all my old 8-space tabs (in older pages, where the child really is 8 spots indented) get turned to 2 spaces as well, which screws up nesting.
So this isn't a big deal with readability then? I mean other Web Devs who check the source out on their system / in their text editor aren't going to freak out over two spaces are they?
It's actually a religious thing. You know how that goes.
Many web devs can take someone else's code in have it indented the way they like— I see Paul O'B uses Dreamweaver to do this for him, when he's working on others' code.
I agree. I don't want crazy indentation all over the place to the point where horizontal scrolling occurs. I hate that. However, for consistency among the source, should we not indent the <head></head> and <body></body as well?
Well, if your personal rule is, two-spaces-per-child-level, then yeah you should, but I don't either. I think of the body and html tags as thuper-thpecial and they fall outside the rules for me.
Code:
<html lang="blah">
<head> indented 2 spaces
<meta> indented child 4 spaces
<title> indented child
<link> indented child
</head>
newline (often, not always, depends on what I had in my coffee)
<body> just not indented, even tho a child of html
<div> first container
<div>
(newlines only between siblings who are really really big)
etc...
</div>
</div>
</body> same level as html here
</html>
Everyone does their own thing. Like I said it's rather a religious thing. My God is better than your God and all that.
Bookmarks