Truncate title to single line & container width

Is there a way to truncate a title to the container width? I'm able to do truncate a long title to one line using the code below, but that doesn't really work for mobile.

h3
    ?php
        $thetitle = $post-post_title;
        $getlength = strlen($thetitle);
        $thelength = 33;
        echo substr($thetitle, 0, $thelength);
        if ($getlength  $thelength) echo "...";
    ?
/h3

Topic content-width php Wordpress

Category Web


how about using CSS3's "text-overflow:ellipsis;" ?

doing so will make sure your title stays in a single line, trimming whatever crossed the container's width limit.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.