Often times I want to target CSS class or ID for a given post type, be it a page, post, archive, or custom post. This allows more control over styling, and obviously can be used in PHP for writing conditional statements.
The example below will output the numeric ID of the current post as well as the post type. An example would be something like class=”21 portfolio”
the_ID(); echo ' '.get_post_type();
https://developer.wordpress.org/reference/functions/get_the_id/
https://developer.wordpress.org/reference/functions/get_post_type/