Electric flux is defined as the number of electric field lines penetrating a surface of a given area that can be either open or closed. Consider an open surface with many tiny elements with area dA placed in an electric field. The area is made as a vector with the same magnitude as the area of the element and the direction perpendicular to the element. The flux through each element is given by the dot product of the electric field and the area vector. The net flux is obtained by integrating this product over the entire surface. If the surface is closed with electric charges inside it, the electric field lines penetrate through the surface. The area vectors point in different directions, always from inside to outside. The net electric flux can then be obtained similarly as before. The flux can be either positive or negative based on whether it enters or leaves the surface and is determined by the type of charge that creates the electric field.