During the Declare Attackers Step, the active player first receives priority and may take actions (including activating mana abilities) before declaring attackers. Mana abilities can be activated at any time a player has priority, per CR 605.3a.
However, here is the critical catch: when you declare a creature as an attacker, it must be untapped at that moment (CR 508.1a). Tapping a creature for mana before declaring attackers means that creature is now tapped and therefore cannot be declared as an attacker in that same step.
So the sequence matters enormously. You can tap a creature for mana, but doing so removes it from the pool of eligible attackers for that combat. If you want a creature to both attack and produce mana this turn, you would need to tap it for mana on a different turn, or use an ability that untaps it afterward.
Concrete example: You control a Llanowar Elves and a Grizzly Bears. During the Declare Attackers Step, you activate Llanowar Elves' mana ability, tapping it for {G}. You may then spend that mana, but the Elves are now tapped and cannot be declared as an attacker. You may still declare Grizzly Bears as an attacker normally.
Reference rules: CR 508.1a (attackers must be untapped when declared), CR 605.3a (mana abilities may be activated whenever a player has priority).
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.