Search code examples
phphtmlcssline

How can I add a horizontal line in php after some text?


I do know how to add horizontal line in html by using <hr> but I am not sure how to do in php.

My code:

  echo '<div class="grid">';
            echo '<p>' .  $row["title"] . '</p>';
            
            echo '</div>';

I want a line here like (________________) on the website after the $row["title"]

I tried doing this:

echo <hr style="width:50%; text-align:left;margin-left:0">;

But it doesn't seem to work. How can I add the horizontal line? Also, I would like to style it with a color, so something like a colored horizontal line such as yellow or any color?


Solution

  • Try the changes below

    Change this:

    echo '<div class="grid">';
    echo '<p>' .  $row["title"] . '</p>';
    echo '</div>';
    

    To this:

    echo '<div class="grid">' . '<p>' .  $row["title"] . '</p>' . '</div>';
    echo '<hr/>';
    

    This should work depend on your parent container width. More how to use this break you can find here: HTML <hr> Tag