User error may be a distinct possibility since [a] most code examples from reputable sources are likely to have been tested properly before they are made available (promote duff code and your peers will notice) and [b] many code examples are basically similar and can be traced back to common sources. Check Hot Scripts (click here) for a variety, all with ratings.
Which local server are you using (if any), by the way? If you have not already got one, try XAMPP.
For CSS, start at Sitepoint (click here) and then buy some books, such as Sitepoint's own or those by Andy Budd or Eric Meyer. Oh, and check out the code refs at Dev Guru (click here)