How to hide HTML tags from SEO spiders

I understand and know how hiding things from your website works and how the search engine spiders will still be able to ¨see¨ this hidden element and penalize your website for it.

Thing is, I did not find any information on how to hide these HTML elements visually AND also hide them from the search engine spiders. Therefore by doing so, hiding HTML element won't be considered Black Hat SEO or Cloaking by web spiders, so your page won't suffer further repercussions.
I mean, in the end you just want to hide things from both! the user and the spider...

I mean, I know it might be a dumb question to ask, like: ¨Why don't you just remove the freaking tag from your page source and that's it?¨¨

But to be honest, I'm just intrigued if this even something doable?

It would be useful to know if for example, let's say that you're working on a website template which you have no access to its core files so you can't just go in there and simply remove the tag and the only thing you can actually edit it's the CSS file.

I just really want to know if this is doable somehow for educational purposes.