The way I do this is to hide certain elements with CSS, then use javascript to unhide them, that way if they don't have javascript, the element remains hidden.
So you still have to use javascript then to do it, because i may aswell just write the html with javascript, unless there is a specific advantage of doing it this way?
But if you have JS disabled and no (or limited) CSS support (e.g. a basic mobile phone web browser), they might still see the 'javascript-only' text, as the CSS rule to hide it might not get applied. If the text must only be visible to people with JS enabled, the safest way is to have JS write it there in the first place.
So you still have to use javascript then to do it, because i may aswell just write the html with javascript, unless there is a specific advantage of doing it this way?