The epigenetic marking of chromatin provides a ubiquitous means for cells to shape and maintain their identity, and to react to environmental stimuli via specific remodeling. Such an epigenetic code of the core components of chromatin, DNA and histone proteins, can thus be stable but is also highly dynamic. In the nervous system, epigenetic codes are critical for basic cellular processes such as synaptic plasticity, and for complex behaviours such as learning and memory. At the same time, epigenetic marks can be stably transmitted through mitosis and meiosis, and thereby underlie non-genomic transgenerational inheritance of behavioural traits. In this review, we describe recent findings on the role and mechanisms of epigenetic codes in the brain, and discuss their implication in synaptic plasticity, cognitive functions and psychiatric disorders. We provide examples of transgenerational inheritance of epigenetic marks that affect simple morphological traits or complex processes such as disease susceptibility, and point to the potential implication of epigenetic codes in medicine and evolution.