<IMG CLASS=icon SRC=\ref[src.w_uniform.icon] ICONSTATE=[src.w_uniform.icon_state]>

Problem description:
I would like to insert an icon from a .dmi file into html and then have it displayed in a browse() window. Currently the code appears to ignore the desired icon state, only using the first icon in the .dmi file (debugging the w_uniform values suggests they are set correctly). How do I reference a specific icon_state in a .dmi?
You're missing the opening [ on the ICONSTATE part.
That was sloppy typing on my part. It does have an opening [.
In my tests I did notice that it wasn't always working unless I had the SRC element's contents surrounded by '' as well, but it did seem to occasionally manage (could have been a cache thing).

So you may want to give that a shot, everything seems to work as expected when I do

<IMG CLASS=icon SRC='\ref[src.icon]' ICONSTATE=[src.icon_state]>

Which is no different than what you're doing (variable usage wise) if the two values are indeed correct.
I have tried your suggestion and also cleared the cache but it did not resolve the issue. The src.icon points to the right .dmi file and src.icon_state is the right state but it always displays the first image in the file.

NB I am using the latest BYOND version 512.1463.
Not seeing any issues on my end at all, that line I posted should always show the right state as long as it exists and isn't named the same thing as another state.
is that the right apostrophe on the icon state? Isnt that the fancy unicode one?
It is hex 92 so it's extended ascii. But it didn't work for ' or \" either. In any case I have found a workaround. Save the icon to the cache and then parse it in base64. No clue why it was not working.