I also find hornwort a bit messy. It does not stay put generally. I've tried a couple of different methods with it and am having decent success. I usually strip off some of the leaves at the "bottom" on a strand of it and push that end deep into the gravel. It will usually stay in place for a while, usually until I clean that part of the gravel.
Another thing I do is wedge it in between and under rocks. Again, it stays in place until I clean the tank and move the rocks around. Pieces do break off but they keep growing. I don't mind a few pieces floating around the tank, so sometimes I'll just let it go. Other times I take some of the smaller pieces and replant them or else I just throw them away.
I raised my lighting from 1.7 to 2.3 watts per gallon and the plant seemed to do better. It also seemed to benefit from adding some liquid fertilizer. When it does not grow well, I noticed that new growth takes on a brownish color and then starts to turn black. With good growth it is usually bright green.
Someone else mentioned anacharis. I think this is a better plant for low to moderate lighting. I bought 3 anacharis plants when I first set up my tank and it has grown to at least 3 times the size. It also roots fairly well and is easy to replant. I am considering replacing my hornwort with anacharis as it continues to grow. It just seems like an easier plant to maintain and is prettier in my opinion, as well.