elegance is very subjective I read a letter conversation between friedrich schiller and sigmund freud about aesthetics and how one might pinpoint/define them and they wrote a lot about how to defined it in the end it was not a clear solution more of a rough estimation to get close to it .....
personally I think there are different types of elegance -> functional elegance, syntactic elegance, structural elegance they could be all together but 90% of the time the community talks about the superficial parts -> structure and syntax.
since elegance is very much based on context so an elegant solution for a web-app can be a crude solution for a desktop-app.
Tough question ... even if the code is elegant in structure (classic clean code approach) is it elegant in function ? a mathematical equation which can be elegant in functional semantics, can be ugly in imperative syntax ...
.....