Hip hop would be considered the genre, and since it’s inception, hip hop has been composed of four major pillars:
MC’ing (Rapping)
DJ’ing
Graffiti Art
Breakdancing
One could make the argument that hip hop is more than just a genre of music. An argument could be made to consider hip hop as a lifestyle.
Now, as for rap. If we go back and notice the four pillars of hip hop, we notice MC’ing (rapping) is one of them. Rap itself is the act of rapping, or rhyming over a beat to form a song or freestyle (free form rhyming). Some examples of “rap artists” are: Jay-Z, NaS, DMX, to name a few.
Trap on the other hand is a label given to artists who rap and who tend to have drugdealing past in south, which is evident in their subject matter/rhymes. This is particularly evident in Atlanta. Atlanta rapper T.I. was the one who coined the term initially. Trap songs also carry musical characteristics that help distinguish it from the rest of rap music, most noticeably the drums and the way they’re programmed. In a trap song, it’s common to have very fast hi hats, have then stutter from time to time, and make good use of 808 kicks which are very sub heavy.
As the name/label trap has evolved, its also used to describe the type of production a song has, moreso than it’s initial definition of drugdealing subject matter in the music. That aspect still lives on, but other genres such as EDM have borrowed and morphed trap (specifically the drums) and infused it with other melodic structures to from new blends of electronic music.
Some examples of trap artists are: Gucci Mane, Future, T.I., Lil Baby, Young Thug
Overall, any trap artist, and any rap artist can be and are considered hip hop artists as well because hip hop is the overall genre that encompasses rap and trap. However, keep in mind that some people will use rap or hip hop interchangeably to refer to the same thing. Technically there is a difference in definition, but depending on the context of the conversation either term can be used to describe the genre of music that deals with rhyming over a beat.