Properly formatted html

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Properly formatted html

Post by shiznatix »

Ok so I always try to write my html like i write my php, with proper indentation and all that jazz. The biggest problem though is that it adds in an extra space in links and whatnot when I try to do the stepping. Example:

Code: Select all

<div>
    <a href="afdasdfsf">
        Click Here!
    </a>
</div>
That will add an extra space after the ! so if its underlined, then there is a blank space underlined. I want to use this style as it makes my life so much easier when trying to go back and edit html and also helps keep things consistent at work so I dont have to fight my way through some insane Fireworks HTML to make the smallest change.

Is there any CSS or something that auto trims blank spaces to avoid this behavior or maybe another idea to fix this?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

There shouldn't be a space there, browsers ignore whitespace unless it's between two other characters. I'm not sure why your browser is rendering that space... strange.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

keep in mind that there are two types of xhtml elements: block element and inline elements. <a> tags are inline element, and should not be indented, IMO. The browser will render up to 1 space before and after the content if there are any spaces at all.

Code: Select all

<div><!-- block element, so indent -->
    <p><!-- block element, so indent -->
        <a href="afdasdfsf">Click Here</a> for more information about <em>cool stuff</em> <!-- both inline elements, so don't indent -->
   </p>

</div> 
Does that make sense?
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Kieran Huggins wrote:<a> tags are inline element, and should not be indented, IMO.
/agree
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

i see what you mean with the inline and block elements. I dont like it because i want to treat all tags the same as it makes my life easier but i suppose you gotta do it. *le sigh*
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Could always do

Code: Select all

<div
    ><a href="afdasdfsf"
        >Click Here!</a
></div>
;)
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

feyd: whoa, that's a bit mental.

kieran: I never thought of making that distinction but that makes a lot of sense. I'm growing to respect you on just about anything to do with client side code.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

ole wrote:feyd: whoa, that's a bit mental.

kieran: I never thought of making that distinction but that makes a lot of sense. I'm growing to respect you on just about anything to do with client side code.
mwahaha! Another one fooled! ;-)

Incidentally, you've inspired me to start making UMLs... who knows, before long I'll be muttering "unit testing...unit testing..." while writing my controllers !!! :twisted:
Post Reply