<!DOCTYPE html>

<style>
[attr] div {
    color: red;
}

[attr] .baz {
    color: blue;
}
</style>

<div id="a">
    <div id="bar" attr="attr">
        <div id="baz" class="baz">
            This should be blue.
        </div>
    </div>
</div>
