The size-density relation of extragalactic H II regions