Question

I have a text coming from a sql db that is not capitalized.

In my HTML, I usually apply CSS text-transform to capitalize the text, but now I face an issue:

I want this text to be part of the title of my site. However, I cannot style within the title.

How could I style the text, then grab it on PHP and then plug it into my title?

Here is what I tried which did not work:

<title>Shop - <p style="text-transform:capitalize;"><?php echo $row2['name'];?></p></title>

Thanks!

Was it helpful?

Solution 2

Use PHP functions ucfirst, ucwords, strtoupper depending on what you need.

ucfirst($row2['name']);

OTHER TIPS

You need to use PHP transformation.

<?php echo ucfirst($row2['name']); ?>

There are quite a few functions you can use for this, ucfirst, ucwords, strtoupper.

As W3C notes, you should only use text, and with a max length of 64 characters:

The title is not part of the text of the document, but is a property of the whole document. It may not contain anchors, paragraph marks, or highlighting.

PHP has a few functions to capitalize text:

ucwords($text)

http://php.net/manual/en/function.ucwords.php

strtoupper($text)

http://www.php.net/manual/en/function.strtoupper.php

you can use

ucfirst($row2['name']) 

You can just use this function in php to echo your text in uppercase: http://php.net/manual/en/function.strtoupper.php
http://php.net/manual/en/function.ucfirst.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top