I'm on H1B and about to switch jobs. Is it possible for me to have a gap between these jobs? Does employment need to continuous?
You legally have 60 days to be unemployed while you file for another H1B.
No. If your employment is ended for any reason ( resign, layoff,...) you still have 60 days to find another job.
Unless you have a paycheck coming from at least one company during the transition, uscis doesn’t care much
No
Keep your paystubs contiguous. Rest is noise.
It used to be unclear and a 30-day grace period was generally accepted, but there was no clear guidelines. In 2016 the USCIS clarified that and now there's an official 60 days grace period after you loose your job for any reason before you find a new job or leave the country. Source: https://www.uscis.gov/news/news-releases/uscis-publishes-final-rule-certain-employment-based-immigrant-and-nonimmigrant-visa-programs
For a gap between jobs, you have a grace period of up to 60 consecutive days after termination of employment during which you need to file for transfer of your work visa. However, it should be noted that the grace period is shortened or does not apply in cases where the authorized stay (generally shown on I-94) is about to expire or has expired.
Better to check online. Most people i have seem have their last working day on Fridays and new job start day as the following Monday. You can always take the last week as PTO at your current employer.