Reputation: 210
I have this PHP code on my website:
<?php
$usernametext = "<p style=" . '"' . "color:#969CB3;font-size:120%" . '"' . ">Username: </p>" . "<p style=" . '"' . "color:black;font-size:150%" . '"' . ">";
echo $usernametext . htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8');
?>
But this is what it displays as.
I want it to be on one line and display like this.
The <p>
tags (with styling) create a line break (or two) which I don't want. I have tried to put the <p>
tags out of the PHP and had no luck. Is this possible to do?
Upvotes: 2
Views: 6647
Reputation: 4584
add display :inline property for that ...
<style>
p {
display :inline;
}
</style>
<?php
$usernametext = "<p style=" . '"' . "color:#969CB3;font-size:120%" . '"' . ">Username: </p>" . "<p style=" . '"' . "color:black;font-size:150%" . '"' . ">";
echo $usernametext . htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8');
?>
Upvotes: 0
Reputation: 1358
the <p>
is not the right one for your work you should use an inline tag such as <span>
see this it may be helpful
<?php
$usernametext = "<span style=" . '"' . "color:#969CB3;font-size:120%" . '"' . ">Username: </span>" . "<span style=" . '"' . "color:black;font-size:150%" . '"' . ">";
echo $usernametext . htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8');
?>
and here is a Snippet for it
<span>username is</span>
<span>XYZ</span>
color:#969CB3;font-size:120%
<span>username is<span>
<span>XYZ</span>
Upvotes: 1
Reputation: 155
Easy, change p to span since by definition, each p represents a new paragraph (probabily there is a way to avoid line break when using p, but this approach doesn't pays off).
Upvotes: 0
Reputation: 235
Use span tag instead of p tag
<?php
$usernametext = "<span style=" . '"' . "color:#969CB3;font-size:120%" . '"' . ">Username: </span>" . "<span style=" . '"' . "color:black;font-size:150%" . '"' . ">";
echo $usernametext . htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8');
?>
Upvotes: 3