PGF manual Section 14:
Some options only apply to the path as a whole. For example, the color=
option for determining the color used for, say, drawing the path always applies to all parts of the path. If several different colors are given for different parts of the path, only the last one (on the outermost scope) "wins".
fill opacity
is one of such "global" styles; it is in effect for the entire path
. That's why
\draw [fill=teal] rectangle ++ (1,-1)
[fill=brown] rectangle ++(1,1)
[fill=red] rectangle ++(1,-1);
yields three red squares because the last fill=red
style wins.

PGF manual Section 23.2:
In addition to filling operations, this opacity (/tikz/fill opacity
) also applies to text and images.
That's why the global fill opacity
setting also affects the node text in the same path
.
Finally, why the "global" style of fill opacity
can be "locally" overridden in a node
that appears in the same path
? PGF manual Section 14 also mentions that
... the nodes are not part of the path in any way. Rather, after everything has been
done with the path what is specified by the path options (like filling and drawing the path due to a fill
and a draw
option somewhere in the specification), the nodes are added in a post-processing step.
So the node is constructed in a different path with styles inheritted from the "parent" path, and these styles can be safely overridden without affecting the parent path.
P.S. You can also set text opacity=1
for opaque texts; it overrides the fill opacity
setting for texts only.
/tikz/fill opacity
: In addition to filling operations, this opacity also applies to text and images.fill opacity
is inherited. Is there any technical reason?fill opacity
to behave as you expect byfill opacity/.append style={text opacity=1}