In some statess, such as Pennsylvania, the state constitution prohibits special legislation; it is often possible for the legislature to evade this restriction by describing the community in great detail without mentioning its name. (For example, Pennsylvania law defines certain powers of "cities of the second class", which was originally defined specifically to apply only to Pittsburgh; the lower threshold of this class has been revised downward to accomodate a decline in Pittsburgh's population, with the effect that other cities not originally envisioned have become entitled to second-class status.)
At the opposite end of the spectrum, in some states -- particularly the New England states -- the state legislature has plenary authority over municipalities, and may create or abolish them, or change their governing laws, at will. These states typically have very weak traditions of home rule, such that any significant legal change to a city or town's charter or governing laws, or an agreement between municipalities, must be authorized by an act of the legislature. There is usually a legal process by which a community may petition the legislature for such a change, and the outcome of this process, if the legislature consents, is special legislation.
The term "special legislation" may also apply in some states to legislation which names a particular person, as in appointment to a government position or conveyance of real property between an individual and the state, or between an individual and an unincorporated community.