Page 1 of 1

Properly formatted html

Posted: Mon Jan 29, 2007 11:56 am
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?

Posted: Mon Jan 29, 2007 12:06 pm
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.

Posted: Mon Jan 29, 2007 12:15 pm
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?

Posted: Mon Jan 29, 2007 12:17 pm
by daedalus__
Kieran Huggins wrote:<a> tags are inline element, and should not be indented, IMO.
/agree

Posted: Mon Jan 29, 2007 12:46 pm
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*

Posted: Mon Jan 29, 2007 1:56 pm
by feyd
Could always do

Code: Select all

<div
    ><a href="afdasdfsf"
        >Click Here!</a
></div>
;)

Posted: Mon Jan 29, 2007 3:06 pm
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.

Posted: Mon Jan 29, 2007 3:41 pm
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: