What you have there is idiomatic HTML generation
No problem with that - if you're happy to maintain it. As others have said, it is the final response that is important.
How can you check your response?
Use the Web Developer toolbar for Firefox, which will manage access to these validation sites from W3C:
- XHTML validator
- CSS validator
Ideally, you should target XHTML Strict but your requirements may vary.
And the search engine?
It won't see how you generate the response, it will only see the response. Search engines on the whole prefer to see well-formed, standards compliant XHTML simply because it's easier for them to parse. However, check out the Google web master notes for what they look for in order to promote your site to the top of the search results. (Hint: Google wants timely, relevant content that is considered to be the definitive resource as a result of others approving it).
` and `
– Josh K Dec 10 '10 at 17:03