MyBB Community Forums

Full Version: Every Little "Character/Tag" Counts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
While working on a template not to long ago I've come to realize how important every little "<br>, </div>, <hr>, <span>, &, #, ., etc...counts!

If you leave out just one "</div>" for example, could throw everything else off!

Which happened to me about just minutes ago, before I fixed it.

I have been adapting myself into the habit of tiding up coding to keep it organized and clean throughout.

A motto I'm trying to keep is...

"If it doesn't belong there, throw it out...and if you need it and it ain't there, throw it in."
The simplest way to prevent this is to organize it so it's easy to read (one tag per a line isn't a bad practices (obviously <strong> doesn't need its own line though). And, also write the closing tag as soon as you write the opening one (if your editor doesn't do this for you already).
Always indent, it will save you tons of headaches.

<header>
	<div class='pageWidth'>
		<div class='branding'>
			<h1>Hello, world</h1>
		</div>
	</div>
</header>
(2012-10-01, 01:15 AM)CAwesome Wrote: [ -> ]Always indent, it will save you tons of headaches.

<header>
	<div class='pageWidth'>
		<div class='branding'>
			<h1>Hello, world</h1>
		</div>
	</div>
</header>

This. If you get in the habit early, it'll help in the long run, especially if you ever get into coding.
When coding syntax is vital. One character will cause an error. Many lazy html writers don't even bother to validate as long as the display is fine but I always want 100% validation.
It always confuses me when all of these writers code their pages in broken HTML then complain when they have to hack all of these browser-specific fixes in. Sticking to standards is the easiest way to get a consistent layout across browsers. Once you've gotten a stable, consistent base to work off of, then you can start with the browser hacks.

My designs may be mediocre but at least they work the same across all the browsers.
Hm, your post confuses me. The only way to break browser compatibility is by using HTML5 (Tags like <footer> don't display in old browsers unless you use html5shiv). Any other HTML/XHTML/mix of the two displays in everything afaik.

Maybe you're talking about CSS, that you have to use browser specific codes, though those don't break most of the time either (things like border-radius, box-shadow, text-shadow) they just simply don't display.

But anyways, indentation will definitely save you loads of time, so I definitely suggest it.
One of the little perks about using XHP is it forces you to write valid HTML or it throws a fit and won't run the code. It would be nice if templating engines (even browsers perhaps but maybe that's going too far) would force validity of HTML. There wouldn't be any excuse not to write valid HTML then. Wink
I'll just leave this here.
http://validator.w3.org/