Snippet varying upon uid

Sorry for such a basic question but my php skills are limited.
I used a snippet for fetching children of a page in the page template.
But I would like to change only 1 line in this snippet (a class actually) depending on which page (uid) it has been called from
I am using something like

    <?php if($page->uid() == 'books'): ?>
    do ...
    <?php if($page->uid() == 'dossiers'): ?>

Is there a simpler way to get the same result or to have the class variable with uid ?
Thank you for your help

If all you want is to add a class, you can do this:

<div class="<?= $page->uid() ?>">

Otherwise, you would have to use an if statement like above.

Thank you for such prompt anwser.
But how to define the corresponding class in the css file ?

I’m not quite sure what you mean? Like this:

.books {
  width: 100%;
  // some more styles

.dossiers {
// some other styles

That’s it !
The class should be named as the uid.
I will try this way
Thank you