die Kappe
cap
A head covering with a brim, worn especially in leisure time, similar to a baseball cap.
Er trägt bei Sonnenschein immer eine Kappe.
He always wears a cap when it's sunny.

cap
Loading your saved state.
cap
A head covering with a brim, worn especially in leisure time, similar to a baseball cap.
Er trägt bei Sonnenschein immer eine Kappe.
He always wears a cap when it's sunny.

The meaning of 'Kappe' (cap) becomes clear from the verb in the sentence. Verbs like 'tragen' (to wear), 'aufsetzen' (to put on), or 'aufhaben' (to have on) refer to the head covering. Verbs like 'aufstecken' (to put on), 'zuschrauben' (to screw on), or 'abnehmen' (to take off) refer to the lid.
Bei dem Wind hat er seine Kappe fest aufgesetzt.
In that wind, he put his cap on tightly.
When 'Kappe' (cap) means a head covering, it is often used with the verbs 'tragen' (to wear), 'aufhaben' (to have on; state), or 'aufsetzen' (to put on; action).
Er trägt fast immer eine Kappe, auch im Haus.
He almost always wears a cap, even indoors.
When 'Kappe' (cap/lid) means a lid, it is often connected with the object that it closes. Typical formulations are 'die Kappe auf den Stift stecken' (to put the cap on the pen) or 'die Kappe von der Flasche nehmen' (to take the cap off the bottle).
Nach dem Schreiben solltest du die Kappe wieder auf den Stift stecken.
After writing, you should put the cap back on the pen.
The idiom 'etwas auf seine Kappe nehmen' (to take the blame/responsibility for something) is a fixed structure. The possessive pronoun ('seine') is adapted to the person taking responsibility.
Das war mein Fehler, das nehme ich auf meine Kappe.
That was my mistake; I'll take the blame for it.
hat
'der Hut' and 'die Kappe' are both head coverings. A hat usually has a fixed shape and often a brim all the way around. Depending on the type, it may seem more classic, elegant, or like protection from the sun. A cap typically has a brim at the front and is often worn in leisure time, like a baseball cap. Learners may confuse the words because both are worn on the head. As a simple guide: with a brim all around, you are more likely to say 'Hut'; with a brim at the front, you are more likely to say 'Kappe'.

Mein Bruder nimmt morgen seine rote Kappe zum Training mit.
My brother is taking his red cap to training tomorrow.
Im Sommer trägt mein Vater gern einen hellen Hut.
In summer, my father likes to wear a light-colored hat.