We present numerical simulations of galaxy formation, including star formation, in a standard, hierarchical cosmological scenario (CDM). The gas dynamics is followed with the Smooth Particle Hydrodynamics (SPH) method, and the gravitational interaction with a tree method. The scales involved range from 20 Mpc down to less than 1 kpc in massive objects. The gas component is treated as a two-phase medium, where the hot component cools radiatively and forms cold clouds through the thermal instability mechanism. Star formation subsequently takes place in the cold clouds. Supernovae heat the hot component and evaporate cold clouds. Metal enrichment is included, and its effect on radiative cooling rates is taken into account. For a certain degree of supernova evaporation, several general properties of elliptical galaxies are reproduced, like shapes, r(1/4)-profiles, half-light radii, slow rotation and anisotropic velocity dispersions. A Faber-Jackson like relation is observed, being of the form M similar to sigma(2.6). Objects with circular velocities down to around 150 km s(-1) can be dynamically and structurally resolved. No disc-shaped objects form. The elliptical objects form predominantly by early hierarchical merging. The thermal instability is the main mechanism for breaking an otherwise purely gaseous collapse. The SFR has a rapidly rising and later exponentially decaying behaviour in individual objects. Cosmologically, the stellar contribution to the closure density is around one percent. The co-moving average SFR increases with redshift, in rough agreement with observations. Low mass objects are strongly suppressed, having small stellar content, and stop forming stars early. Generally, the more massive objects are in place at z similar to 0.5-2. Although many problems and questions still remain, the overall impression is that, surprisingly, many properties of ellipticals are reproduced. These results are also largely in agreement with those presented by Yepes et al. (1997), but the simulations presented here are of higher spatial resolution, and can thereby resolve at least the more massive galactic objects (upsilon(circ) > 150 km s(-1)).