The most reliable way to make changes to the Document Object Model is by utilizing JavaScript. The DOM serves as a framework for interacting with different parts of a website, and nothing beyond that.
Unless you have an aversion to using JavaScript and prefer something like client-side VBScript (specific to IE), JavaScript is your best option.
If you are looking for a similar effect, experimenting with CSS pseudo-elements may be worth trying, although they may not fully meet your requirements. Additionally, CSS pseudo-elements do come with some drawbacks; for instance, text contained within pseudo-elements cannot be selected.
In essence, JavaScript is necessary for manipulating the DOM effectively, as it is a structure rather than a language in itself.