Technically, in most gaming jurisdictions, it’s not illegal to count cards while you play blackjack, but casino employees can and will back you off the game table if they get the hint that you are counting cards.
Counting cards while playing blackjack could give you that 1%-plus advantage, but expect a pit boss to come up and pleasantly say: “Excuse me sir, we appreciate your patronage, but we’re going to have to ask you to stop playing blackjack here. Feel free to play any of the other table games we offer at our establishment.”
Not all casinos bar counters. Atlantic City, by law, cann’t ask you to back off a blackjack game. Of course, it’s legal to use your brain. A few ways casinos do to keep skilled counters at bay are by having tougher blackjack rules, multi-deck blackjack games and limited deck penetration.