http://support.apple.com/kb/HT5523
This lists the specifications that the RAM must comply with to be compatible.
http://support.apple.com/kb/HT5540?viewlocale=en_US&locale=en_US
This shows the procedure to upgrade the RAM.
The 27" and the 21.5" iMacs are different in that the 27" has a dedicated RAM compartment, accessible from the rear WITHOUT tearing open the screen.
Hope this helps!