The closely related acetyltransferases CBP and p300 are key regulators of gene expression in metazoans. CBP/p300 acetylate several specific lysine residues within nucleosomes, including histone H3 lysine 27 (H3K27), a hallmark of active enhancers and promoters. However, it has remained largely unclear how specificity of CBP/p300 towards H3K27 is achieved. Here we show that the TAZ2 domain of CBP is required for efficient acetylation of H3K27, while curbing activity towards other lysine residues within nucleosomes. We find that TAZ2 is a sequence-independent DNA binding module, promoting interaction between CBP and nucleosomes, thereby enhancing enzymatic activity and regulating substrate specificity of CBP. TAZ2 is further required to stabilize CBP binding to chromatin in mouse embryonic stem cells, facilitating specificity towards H3K27 and modulating gene expression. These findings reveal a crucial role of TAZ2 in regulating H3K27ac, while highlighting the importance of correct site-specific acetylation for proper regulation of gene expression.