The properties of \isotope [ 12 ] { C } , \isotope [ 16 ] { O } , and \isotope [ 20 ] { Ne } nuclei in strong magnetic fields B \simeq 10 ^ { 17 } G are studied in the context of strongly magnetized neutron stars and white dwarfs . The SKY3D code is extended to incorporate the interaction of nucleons with the magnetic field and is utilized to solve the time-independent Hartree-Fock equations with a Skyrme interaction on a Cartesian three-dimensional grid . The numerical solutions demonstrate a number of phenomena , which include a splitting of the energy levels of spin-up and -down nucleons , spontaneous rearrangment of energy levels in \isotope [ 16 ] { O } at a critical field , which leads to jump-like increases of magnetization and proton current in this nucleus , and evolution of the intrinsically deformed \isotope [ 20 ] { Ne } nucleus towards a more spherical shape under increasing field strength . Many of the numerical features can be understood within a simple analytical model based on the occupation by the nucleons of the lowest states of the harmonic oscillator in a magnetic field .