1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Best Practices for XHTML

Discussion in 'HTML & Website Design' started by clinton, Feb 3, 2008.

  1. #1
    1 Don't be lazy, be organized, slipping up once could make more work for you later, and time is money;)

    2. Always use doctypes

    3. An Html doc should always have a <html> tag, head and body

    4. Always add the keyword, description, content-type and language meta tags.

    5. Use divs instead of tables, reason 1. Proper use of tables are for tabular data only, not layouts, images etc. 2. Tables(especially when nested) take longer for the browser to render plus it effects the pages file size.

    6. Use external CSS for styling. Don't use <font size="1" face="Arial"><b>...It makes things very hard to change later on and it also adds to the pages loading time.
    Old Way: <font face="Verdana" size="12"><b>Old way</b></font>
    New improved maintainable way: <b class="SpecialText">New Way</b>

    7. Indent your Html code so it's easy to read. Using tabs is way better than spaces. Reason 1, tabs can be displayed differently in your text editor, Reason 2, hitting the space bar 4 times is much more time consuming than hitting the tab bar once. Reason 3. using spaces instead of tabs greatly increases the file size.
    
    <div>
        <a href="">
            Main
        </a>
    </div>
    
    HTML:
    8. Comment your code.

    9. Keep up to date with XHTML standards since they are the present and future of the web.

    10. ........Please post more
     
    clinton, Feb 3, 2008 IP
  2. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #2
    Why are you double posting.

    And no,

    That's NOT the proper method. You should not be using presentational classes nor elements. You should only be using the right elements for the right job and should almost never have to resort to the bold element.

    <font size=9><b>heading</b></font>

    ^ Old way

    <h1>heading</h1>

    New way. Much simpler, no classitus. I would rather use child selectors and do something like

    Instead of sticking a bunch of useless classes onto the same elements.

    To me the meta keywords is USELESS. I wasn't around at the time, but I know it got pretty abused in the late 90s / early 00s.

    And XHTML is not the future of the web, since 1.0/1.1 won't even be compatible with 2.0. Some elements from HTML 5 are already being implemented in browsers, and even if it's 10-15 years from now it will be more fully supported I predict than XHTML 2.0
     
    soulscratch, Feb 3, 2008 IP
  3. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I find myself defaulting in my css sheets span.bold {font-weight: bold;} span.italic {font-style: italic;} as I keep needing to copy paragraphs from old code which use normal italics and bold simply for styling the text (if something needs to be emphasised I will use strong and em since JAWS reads them differently).

    I add keywords anyway just because it doesn't take much of my time and some of the dumber search engines still look at them and compare them to the content on the rest of the page.

    I use spaces for indenting because if I used an 8-space tab, my pages would become unreadable on my screen. It's too far for me. Two spaces tell me that something is nested x-times in. Body has zero spaces. Everything that is direct child of the body has two spaces in. Their direct children have another two spaces and so on. But that's me-- my tabs all get lost once I turn the code over to me colleague who sets my html in his php template. It's awful.
     
    Stomme poes, Feb 4, 2008 IP
  4. jamesicus

    jamesicus Peon

    Messages:
    477
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I don't know about that. Until MS changes their stance on IE Browsers rendering content (MIME) type application/xhtml+xml (doesn't appear it is going to happen with release of IE8 -- how many more years will it be?) just about all XHTML is being served as HTML anyway (content type text/html) -- check the link in my sig. block. I got tired of contributing to the W3C XHTML 2.0 effort -- I don't when (or even if) that will be implemented. The W3C is now on the HTML5 bandwagon.

    IMO XHTML served as HTML is really a good thing (although it does require some extra header code and you can't practically embed XML) -- it enforces coding well-formedness: for those who do that as a matter of course, might as well use HTML 4.01 (Strict of course).

    James
     
    jamesicus, Feb 4, 2008 IP