A CFD mirrors the price of something else: a currency pair, an index, a share, a commodity. You post margin-requirement rather than the full value, your profit or loss is the price change times the size, and the broker is your counterparty, which is why counterparty-risk applies in a way it does not on an exchange.
The attractions are access and symmetry. One account can trade markets in several countries, shorting is as easy as going long with no borrow to arrange, and position sizes can be small. The costs are the spread or commission, the overnight-financing-charge on every night held, and leverage that magnifies both directions.
CFDs are regulated as retail derivatives in the UK, EU, Australia and elsewhere, with the caps and protections in esma-leverage-caps. They are not generally available to US retail clients, because the contracts would have to trade on a registered exchange.
Example: 500 CFDs on a share at $40 is $20,000 of exposure. At 20% margin you post $4,000. A move to $42 returns $1,000, a 25% gain on the margin from a 5% move in the share.
Related: cfd-vs-spot-fx, overnight-financing-charge, counterparty-risk, esma-leverage-caps