thus looks like the tax number for residents

The spanish tax number comes in two versions:
 

The white versions is for Non-residents:

 

Beispiel-NIE-klein

 

The tax number for in Spain permanently resident foreigners can look like this: