Lifelink causes life gain equal to the total amount of damage dealt by the creature, regardless of what the damage is dealt to (CR 702.15b). Trample allows excess combat damage to be assigned to the defending player or planeswalker after lethal damage is assigned to blockers (CR 702.19b). Both effects apply together with no conflict.
When a trampling creature with lifelink deals damage, it deals damage simultaneously to the blocker(s) and to the defending player. Lifelink triggers (or applies as a static ability in modern rules) based on the total damage dealt — so all of it counts toward life gain (CR 702.15a). There is no rule that limits lifelink to damage dealt to creatures.
Concrete example: You attack with a 6/6 creature with trample and lifelink. Your opponent blocks with a 2/2. You assign 2 damage to the blocker (lethal) and 4 damage to the defending player (trample). Your creature deals 6 total damage, so you gain 6 life.
It does not matter that the excess damage went to a player rather than a creature — lifelink looks only at the total damage output of the creature, not the target of that damage (CR 702.15b, 702.19b).
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.