To expand on travoc's answer, historically San Francisco was banking and finance, Silicon Valley was tech (mostly hardware), and in between was San Mateo County (mostly biotech). While San Francisco did see some web-related startups in the dotcom bubble (mostly around South Park), Salesforce/LinkedIn/Twitter/etc. being headquartered in San Francisco itself is purely a phenomenon of the post-dotcom bust tech boom.
On the Silicon Valley page, the author claims "San Francisco is often considered part of Silicon Valley, but geographically it is not; but also historically it played only a negligible role in the development of Silicon Valley."