The style element will add the CSS classes to your widget, in case there are additional classes added programmatically by the widget itself.
If you want to replace all CSS classes, or you know exactly when the widget will add CSS classes programmatically, then you can use the css-classes property as a newline-separated list of strings:
<object class="SomeWidget">
<property name="css-classes">foo
bar
baz</property>
</object>
Personally, I recommend you use the style element.
That’s exactly the point. I already read the GtkWidget and the GtkBuild docs at least 3 times, but something always slips off because the UI file documentation is scattered through a lot of different places.
When my question came up, I was reading the css-classes property documentation because I got used to look for properties to set from the file, and that took a wrong turn…