For security we are very strict of what HTML attributes can be rendered in our page when they come from user input.
What you can do to get that is:
<div data-my-special-attr="42">
<iframe src="http://example.com">
</div>
and then target that with your CSS / JS selector:
div[data-my-special-attr="42"] > iframe {
border-color: pink;
}