I think that the regular expanding foam is OK as long as it doesn't have chemicals in it (like the Great Stuff Pestblocker). Lots of people make backgrounds out of it and it turns out OK. Some people have had problems with the regular yellowish foam coming apart from exposure to light over time. There are ways to prevent that (for example, paint with Drylok, cover with epoxy, etc.) or use the black pond foam.
Bottom line, I think you'll be OK using it for what you are doing. I'm doing the same thing for my background that I'm building. I carved foam board and glued it together to get the effect that I wanted, but it leaves space between it and the board that I'll attach to the glass, and I'm filling it with Great Stuff (regular yellowish foam). Part of my background that will be exposed to light will be made entirely of the black pond foam, but I'm painting it with Drylok too (not worried about it coming apart, but painting it for cosmetic purposes). Also, beware, because it's very buoyant, so you'll have to secure it to the tank. Are you planning to spray it to the glass? If so, it makes a good bond, but is very difficult to remove if you ever want to change your background. I personally and making mine permanent, so I'm using it as glue also.
To help counter buoyancy issues, I'll be filling the gaps with a combination of river cobble stones and the foam.
Here's my work so far:
Here's a side view where you can see where I'll be filling in the gaps that will be filled with foam, although I've since revised the base:
Bottom line, I think you'll be OK using it for what you are doing. I'm doing the same thing for my background that I'm building. I carved foam board and glued it together to get the effect that I wanted, but it leaves space between it and the board that I'll attach to the glass, and I'm filling it with Great Stuff (regular yellowish foam). Part of my background that will be exposed to light will be made entirely of the black pond foam, but I'm painting it with Drylok too (not worried about it coming apart, but painting it for cosmetic purposes). Also, beware, because it's very buoyant, so you'll have to secure it to the tank. Are you planning to spray it to the glass? If so, it makes a good bond, but is very difficult to remove if you ever want to change your background. I personally and making mine permanent, so I'm using it as glue also.
To help counter buoyancy issues, I'll be filling the gaps with a combination of river cobble stones and the foam.
Here's my work so far:

Here's a side view where you can see where I'll be filling in the gaps that will be filled with foam, although I've since revised the base:
