Build selector with optional prefix ('.', '#' or empty).