Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-18-2012, 02:59 AM   PM User | #1
knightmetal
New Coder

 
Join Date: Sep 2012
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
knightmetal is an unknown quantity at this point
Indenting with HTML

I've been looking at different page sources on the net and I've noticed there are variations in the way the code is usually indented. I would like to know if there are standards to follow as to what's the right indenting technique/style to use or if this is more of a preference?

For example, in some pages, especially parts containing images and links inside ul and li tags, sometimes I see the code horribly piled up which makes it really hard to read. How can someone, even experienced web developers actually read that?

I've gotten used to always hand writing my html and it seems to me it looks sometimes kind of empty as I always try to separate things so that they are easy to read. But then when I randomly choose websites and view the code, often times the codes I see are much more condensed, some of them left-justified, some of them piled up, etc.

I don't have work experience in web development but I do like to develop websites, I'm simply trying to adopt good coding practices. I guess companies take that into consideration when hiring a developer ???

Any comments, suggestions or recommendations on good articles to read will be much appreciated.

Last edited by knightmetal; 09-18-2012 at 03:05 AM..
knightmetal is offline   Reply With Quote
Old 09-18-2012, 03:24 AM   PM User | #2
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
For the most part, it just depends on the programmer's style.

Most programmers indent things with the "tab" key:

Code:
<ul>
    <li></li>
</ul>
However the code you see on a live website is often different than what the programmers developed it with.

Many websites condense their code, some even go as far as condensing it into 1 line (you see that with CSS a lot).
Take a look at these website's CSS: http://www.youtube.com/ https://twitter.com/ (1 line condensed CSS)

If you see code all condensed, chances are they didn't develop it like that. Any experienced programmer would be smart enough to make the code as simple as possible to read while developing (nicely indented), however when it comes to making the code live (putting it on a live website), many large websites with high traffic, condense the code as it speeds up page load time and server load:

HTML compressor CSS compressor

As a beginning developer, you should definitely make your code easy to read, indent things so that you can easily read it and since your websites probably won't get high traffic, I would highly recommend you just publish your code as you wrote it (no need to compress and save half a second).
It's easy to get consumed with how your code looks on view source, but let me reassure you that that will improve naturally with your time in programming.

Sammy12

Last edited by Sammy12; 09-18-2012 at 03:37 AM..
Sammy12 is offline   Reply With Quote
Old 09-18-2012, 10:03 AM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,607
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Also, the indenting cannot always be controlled completely by the developer since many websites run on a server side script (PHP/ASP/JSP…), for example if powered by a CMS, which compiles the pages from snippets and contains a lot of conditionals etc. that might be indented themselves for ease of reading even though you don’t see them in the output source code eventually. So you might see a “dirty” output source code even though the code snippets are “clean” for themselves.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 09-18-2012, 03:24 PM   PM User | #4
knightmetal
New Coder

 
Join Date: Sep 2012
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
knightmetal is an unknown quantity at this point
Guys, thanks a lot for your comments!

I guess my problem is that I don't know what to look at or what to improve in my codes. I've been working on my portfolio lately so that if I get a job offer or something then I'm able to show "something", then they'll know what to expect from me. It's just hard not have friends or someone who can give you tips, suggestions or constructive criticism, even though I know there's plenty of information on the internet about this topic. That's why I decided to turn to forums and clarify the doubts I had.

Your comments were useful, thanks!!!
knightmetal is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:51 PM.


Advertisement
Log in to turn off these ads.