SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Newbie would like help on validating his code

    Hey guys,

    First off, i've started building my own website recently, without any knowledge on how stuff works (so please take it easy on me ).I've used the "learn how to build web sites the right way from scratch" book (together with some web-tutorials) , and wanted to validate my code.

    As in the book, i used xhtml1.0 strict. I have some links to other pages, and use target="_blank" to open those in a new browser. This doesn't pass the validation, and from searching around i realise that the target attribute isn't supported in xhtml1.0 strict, right?

    However, i'm unable to find another way to do this that will be valid. Could you help me out here?

    Along the same lines, i've centered most of the content on my website by putting a "text-align: center;" in the css for the body. It looks fine in IE, but FF just aligns everthing on the left. I think i've found out that center won't work in xhtml, but again, i haven't been able to figure out what else to do that will work.

    Thanks in advance for your help.

    Ps: i've searched the forum. but didn't find a thread that deals with these questions.

  2. #2
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    As far as the target attribute, your best choice is to change it to a Transitional doctype if you want to use the target.

    Though I an others may recommend not setting the links to open in new windows and just let the user decide where they want to open links on your pages. This is better for the user and lets you have a strict doctype.

    As far as the text-align: center; you set it in the body. This is for older versions of IE (i think) you will need to set the text-align property again for the containing element of the content. Assuming you mean the text is all aligned in the center?

    Can we get a link to the page, this will lead to a more accurate assessment.

  3. #3
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    The correct way to center a block level element horizontally is by setting its CSS margins to auto " {margin: 0 auto;} " though usually you set the width of the container too. To fix the old M$IE bug you may want to then use text-align for the contents.

    As for target="_blank" unless you use Transitional it's best to use unobtrusive JavaScript for the new window.

  4. #4
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help .

    Is there any difference in transitional and strict that i should know about before changing the two? I have zero experience with JavaScript, and it hasn't apeared on my "priority-to-learn" list yet, so using transitional seems like the way to go.

    The part of the site that i've been working on is the pages for "manman" (which is me). It's still all in Dutch, but ofcourse that doens't matter for all the markup that i need help with.

    As you'll be able to see, what i would like is that all the block level elements are centered horizontally, the text inside the elements will be centered of aligned on the left, depending of the content.

    I've alreay fixed the width of all the containers on the page, and i'll give using the CSS margins a shot.

    Again, thanks for your help, it's much apreciated.

  5. #5
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by McManaman View Post
    Is there any difference in transitional and strict that i should know about before changing the two? I have zero experience with JavaScript, and it hasn't apeared on my "priority-to-learn" list yet, so using transitional seems like the way to go.
    Transitional just means you're not l33t enough to use Strict yet.

    I would recommend you stick to using Strict if that's what you started with; the reason the target attribute is deprecated is that you shouldn't really be interfering with the browser behaviour within your HTML - let your site's visitors decide for themselves whether they want a link to open in a new window or not.

  6. #6
    SitePoint Addict StuckRUs's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The main reason for not opening new windows is the problem it causes people using screen readers. Unless you have warned them that a new window will open they have no idea it's happened and therefore get totally confused when they try to go back to your site and nothing happens.
    SMILE! everyone will wonder what you're up to.
    Site - under construction - again


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •