NOVELTY - A dye includes an anchoring group in its molecular structure. The anchoring group allows a covalent coupling of the dye to a surface, e.g. a surface of a nanoporous semiconductor layer.    USE - A dye for use in an electronic device, preferably a dye-sensitized solar cell or a chromogenic sensor for detecting the presence, absence or quantity of solvents, e.g. ethanol, methanol and acetonitrile (claimed).    ADVANTAGE - The photostable dye has intense absorption with absorption coefficients of greater than 105 L mole-1 cm-1 in the visible and infrared region of the solar spectrum. The dye has bandgap and energy levels that can be tuned. It can be efficiently chemisorbed to the nanoporous surface of the photoactive layer.    DETAILED DESCRIPTION - A dye includes an anchoring group in its molecular structure. The anchoring group allows a covalent coupling of the dye to a surface, e.g. a surface of a nanoporous semiconductor layer. The anchoring group is of formula asterisk=C(A)-G. Attachment of the anchoring group within the molecular structure of the dye is at the terminal carbon marked with an asterisk.    G=-SO3H, -PO3H2, -BO2H2, -SH, -OH, -NH2, or preferably -COOH;    A=H, -CN, -NO2, -COOR, -COSR, -COR, -CSR, -NCS, -CF3, -CONR2, -OCF3, C6H5-mFm;    m=1-5;    R=H, straight or branched -CnH2n+1 or optionally substituted phenyl or biphenyl; and    n=0-12 (preferably 0-4).    INDEPENDENT CLAIMS are included for: (I) synthesis of a chromophore comprising reacting 2 equivalents of (Ar1-CH3)+Hal- or 2 equivalents of (Ar1=CH2) or 2 equivalents of (Ar1=CH2) with 1 equivalent of squaric acid derivative or croconic acid derivative to yield a squarylium or croconium dye; or forming chloro or alkyl ester of a squaric or croconic acid derivative substituted with one aromatic system Ar1 and condensation with (Ar2-CH3)+Hal- or (Ar2=CH2) to yield a squarylium dye or croconium dye; and (II) synthesis of a dye comprising coupling a chromophore and a conjugated system under transition metal catalysis, introducing a carboxyaldehyde moiety into the conjugated system, and transforming the carboxyaldehyde moiety into an anchoring group by reacting the product with A-CH2-G; or introducing an anchoring group where G is Gp into a functionalized conjugated system, coupling a chromophore and the product under transition metal catalysis, and deprotecting Gp to G; introducing a carboxyaldehyde moiety into a ligand, transforming the carboxyaldehyde moiety into an anchoring group by reacting the product with A-CH2-G, and then reacting with a metal.    Hal-=I-, Br-, Cl-, NCS-, or SCN-;    Ar1, Ar2=one or more of 44 (hetero)aromatic systems of formula (VII);    Z=H, Cl, Br, F, I, NO2, NH2, CN, SO3H, OH, -(CH2)nCH3, -(CH2)n-COOR, -(CH2)n-OR, -(CH2)n-SR, -(CH2)n-NR2, -((CH2)p-O)n-CH3, or one or more of 7 (hetero)aromatic systems of formula (VIII);    R1=H, Cl, Br, F, I, NO2, NH2, CN, SO3H, OH, -(CH2)nCH3, -(CH2)n-COOR, -(CH2)n-OR, -(CH2)n-SR, -(CH2)n-NR2, -((CH2)p-O)n-CH3;    n2=0-12 (preferably 1-7); and    Gp=-COOR, -SO3R, -PO3R2, -BO2R2, -SR, -OR, or -NR2.