Heterochromatin protein 1 (HP1) is a major component of heterochromatin. It was reported to bind to a large number of genes and to many, but not all, transposable elements (TEs). The genomic signals responsible for targeting of HP1 have remained elusive. Here, we use whole-genome and computational approaches to identify genomic features that are predictive of HP1 binding in Drosophila melanogaster. We show that genes in repeat-dense regions are more likely to be bound by HP1, particularly in pericentric chromosomal regions. We also demonstrate that TEs are only bound by HP1 if they are flanked by other repeats, suggesting a cooperative mechanism of binding. Genome-wide DamID mapping of HP1 in larvae and adult flies reveals that repeat-flanked genes typically bind HP1 throughout development, whereas repeat-free genes display developmentally dynamic HP1 association. Furthermore, computational analysis shows that HP1 preferentially binds to transcribed regions of long genes. Finally, we detect low but significant amounts of HP1 along the entire X chromosome in male, but not female, flies, suggesting a link between HP1 and the dosage compensation complex. These results provide insights into the mechanisms of HP1 targeting in the natural genomic context.