The present invention relates to a hair cosmetic containing the following components (A) to (E):(A) a compound represented by the following general formula (1) or a salt thereof:wherein a broken line represents the presence or absence of a π bond; R1 represents a hydroxy group or an acetoxy group; R2 represents a hydrogen atom or -COOR (R is a hydrogen atom, a methyl group, or an ethyl group); and R3 represents a hydrogen atom, an acetyl group, a methyl group, or an ethyl group;(B) an alkaline agent;(C) a buffering agent;(D) an anionic surfactant; and(E) a cationic polymer having a cation charge density of 0.01 meq/g or more and 4.8 meq/g or less,a mass ratio of the component (A) to the component (E) [(A)/(E)] being 0.05 or more and less than 2.