I was told that to calculate the vector that is normal to a surface as shown in the image (please ignore red markings) you take the gradient (partial derivative w/ respect to x), transpose. I do not understand why this is done. How does the gradient, transpose give you the normal vector?

Given a smooth surface consisting of $x \in \mathbb{R}^n$ where $g(x)=0.$ Define a curve $x(t)$ on the surface. Then the tangent vectors $x'(t)$ to the curve are are also tangent to the surface. Also note that $$ \frac{d}{dt} g(x(t))=0 \ \ \ \Rightarrow \text{ (ChainRule)} \ \ \ \nabla g(x(t)) \cdot x'(t) = 0, $$ implying that the gradient $\nabla g(x)$ is orthogonal to the tangent vector at $x.$