1

How to style php output? Here is an code for example? I can only style with css the code who is in the echo.How to style the session value?

 echo "<h1>Logged in as:</h1>"  .$_SESSION['myusername'];

Any tip?

3
  • put session value also in a element for ex: span or div and write inline css Commented Apr 26, 2014 at 16:19
  • echo "<h1>Logged in as:" .$_SESSION['myusername']. "</h1>"; Commented Apr 26, 2014 at 16:22
  • You must have an html element surrounding the session variable - and style that element. How exactly do you want to style it? Commented Apr 26, 2014 at 16:23

2 Answers 2

1

You can use span tag to format text inside h1 tag :

echo "<h1 class='yourClass'>Logged in as:<span class='spanclass'>" .$_SESSION['myusername']. "</span></h1>"

CSS class (for example):

.spanclass{
   color:green;
} 
Sign up to request clarification or add additional context in comments.

Comments

0

Use class to you html in php and add a style to your css file

In css page

.yourClass{

 //add your style

}

In PHP

 echo "<h1 class='yourClass'>Logged in as:</h1>"  .$_SESSION['myusername'];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.