What 'code' are you talking about here? and what do you mean by 'right'? syntactically correct, conforming to known standards, bug free, efficient, compact, easy to maintain?
Valid =/= Right A site can be "valid" and that doesnt either mean that it will display "right" nor that what it is displaying is "right". If your testing the "how" (ie what it looks like) then its a case of checking different browser and OS combinations. There are tools for testing the basic page for free but they won;t check that mouseovers or javascript are right If your testing the "what" (ie that if your logged in it shows your name and not someone elses) then again there are some tools but I don;t know of any free ones and there is a fair learning curve to programme them with test cases (generally only efficient with complex and long forms)
No one other than you knows what the output should be for a specific URL. I would always suggest to learn how to do unit testing and integration testing. Also there is an opensource tool available called selenium provided by Thoughtworks. You can use that to validate that your site throws expected pages only. In fact using selenium you can simulate the whole user experience (each work flow) and run it every time you have done some changes to the site so as to ensure that you haven't broken any existing flow. Hope this helps Regards, Mike