use getElementsByTagName to get head and title elements