A valve for liquid or gaseous media, comprising - a valve body, - which comprises a valve chamber, - which can be brought into a fluid connection with at least one inlet and with at least one outlet, comprising - a valve device, which can be displaced into a first and a second functional position, - which prevents the fluid connection between the at least one inlet and the valve chamber in the first functional position and releases it in the second functional position, wherein - the valve device has a sealing element, which can be pressed against a valve seat so as to form a seal in order to close the inlet in the first functional position, comprising - a biasing element, which pushes the valve device into its first functional position by means of a biasing force, comprising - a drive, which cooperates with the valve device and which displaces said valve device, and comprising - an elastic pressure compensating element, which is coupled so as to form a seal to the valve device on the one hand and to the valve body on the other hand in such a way that it defines the valve chamber against a pressure compensating chamber, which is connected to the at least one inlet via a fluid path, so that - the pressure prevailing in the pressure compensating chamber on the one hand and the pressure prevailing in the at least one outlet on the other hand can be applied to the pressure compensating element, and that - the surface of the valve device, to which the pressure prevailing in the inlet is applied at the valve seat, corresponds essentially to the surface of the pressure compensating element, to which the pressure prevailing in the pressure compensating chamber is applied, characterised in that - the pressure compensating element is secured to the valve device and/or to the valve body in such a way that the surfaces of the pressure compensating element, to which the pressure of the pressure compensating chamber and/or of the valve chamber is applied, change at least in response to a displacement of the valve device from the second functional position into the first functional position in such a way that the surface, to which the pressure of the pressure compensating chamber is applied, becomes larger than the surface, to which the pressure of the valve chamber is applied. - a valve body, - which comprises a valve chamber, - which can be brought into a fluid connection with at least one inlet and with at least one outlet, comprising - a valve device, which can be displaced into a first and a second functional position, - which prevents the fluid connection between the at least one inlet and the valve chamber in the first functional position and releases it in the second functional position, wherein - the valve device has a sealing element, which can be pressed against a valve seat so as to form a seal in order to close the inlet in the first functional position, comprising - a biasing element, which pushes the valve device into its first functional position by means of a biasing force, comprising - a drive, which cooperates with the valve device and which displaces said valve device, and comprising - an elastic pressure compensating element, which is coupled so as to form a seal to the valve device on the one hand and to the valve body on the other hand in such a way that it defines the valve chamber against a pressure compensating chamber, which is connected to the at least one inlet via a fluid path, so that - the pressure prevailing in the pressure compensating chamber on the one hand and the pressure prevailing in the at least one outlet on the other hand can be applied to the pressure compensating element, and that - the surface of the valve device, to which the pressure prevailing in the inlet is applied at the valve seat, corresponds essentially to the surface of the pressure compensating element, to which the pressure prevailing in the pressure compensating chamber is applied, characterised in that - the pressure compensating element is secured to the valve device and/or to the valve body in such a way that the surfaces of the pressure compensating element, to which the pressure of the pressure compensating chamber and/or of the valve chamber is applied, change at least in response to a displacement of the valve device from the second functional position into the first functional position in such a way that the surface, to which the pressure of the pressure compensating chamber is applied, becomes larger than the surface, to which the pressure of the valve chamber is applied.