New to Kirby: need help assigning CSS classes to PHP generated tags

Hi all,

I’m new to Kirby and I’m starting from the basic template (with an About page, Contact page, and 3 projects). My biggest question so far is: how do I customize using CSS a block of content that is being echoed by the PHP?

For example, I noticed that when I try to use Markdown Extra with a block beginning with “Title:” or “Text:”, that my css style does not get applied and instead the css tag formatted in Markdown Extra translates as if it is part of the “Title:” or “Text:” block.

For example, this is what I have typed up in my home.txt file ({.center} makes text align to centered):

Text: I know. It’s been ages since I’ve put anything nuevo up. {.center}

And it doesn’t seem to work. However, this does work:

# testing this # {.center}

It’s worth noting that I enabled Markdown Extra in my config file. I’ve even tried to modify the php that echoes the Title and Text blocks, by disabling both blocks, but then all the content disappears. Can anyone offer some advice here?

Thank you!!

You cannot apply classes to any text block. It only works with certain elements:

At this time, special attribute blocks can be used with

fenced code blocks,
links, and
PHP Markdown Extra

If you need classes for text blocks, you can use html tags within your markdown.

Other than that, you might try to reorganize the way you structure your text and apply your classes in the templates.

Ok, I think that makes sense. I tried using the fenced code blocks but that seems to break too; seem like inline styling using html will have to do.

Also, is it a requirement that every page have a Title and Text block? Or is that something I can manipulate via the PHP? I tried to get rid of the two instances of each but then creating a new div for new text doesn’t appear in the preview.

The title field is required, at least if you use the panel, the text field is not necessary.

You can also use Kirbytext tags for styling if you create your own tags: