When the pages are served to the customer (or the validator) their dynamic content was already parsed by the server, thus they receive a static page. Meaning yes, dynamic pages can be validated the same as static.
On your problem, the first thing you need to specify when creating a page it is the set of rules which your page will follow. This is called a Document Type Declaration or DOCTYPE for short. What you do is point your page to a declaration at the w3c server which checks which elements and attributes it can use and which to ignore.
First thing you need to do is decide between HTML (less strict) or XHTML (more strict). They are the same languages, the difference is in the strictness. With both you will face additional options in Transitional (less strict) and Strict (more strict). Consult the
for complete information on the DOCTYPES. Here's a short example:
<DIV id=container><img src="..." alt="" border="0" /><br></DIV>
in HTML 4.01 this code would probably validate.
in XHTML Transitional this would not validate yielding the following errors: capital letters for element name and attributes (only small letters are allowed in XHTML), no quotes for id attribute (all attributes have to be "double-quoted"

, tags not closed (ALL tags have to be closed in XHTML even single ones - <br />)
in XHTML Strict in addition to Transitional errors, border="0" is not a valid attribute for the img and would be ignored.
Hope it helps.