Science, Tech, Math › Computer Science Formatting PHP Text Formating PHP Text Using HTML Share Flipboard Email Print Georgijevic/Getty Images Computer Science PHP Programming Tutorials MySQL Commands Perl Python Java Programming Javascript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More By Angela Bradley Angela Bradley Computer Science Expert B.A, History, Eastern Oregon University Angela Bradley is a web designer and programming expert with over 15 years of experience. An expert in iOS software design and development, she specializes in building technical hybrid platforms. Learn about our Editorial Process Updated on August 20, 2017 So you've gone through the PHP tutorials or are new to PHP in general, and you can make some nifty things in PHP, but they all look like plain text. How do you jazz them up? Formatting PHP text isn't done with PHP; it's done with HTML. You can do this in two ways. You can add HTML inside the PHP code or you can add the PHP code inside the HTML. Either way, the file must be saved as a .php or another file type that is allowed to execute PHP on your server. Changing PHP Text Color Using HTML Inside PHP For example, to change the PHP text color to red. Hello World!"; ?> In this case, the hex color number #ff0000 sets the PHP text that follows it to red. The number could be replaced by other hex color numbers for other colors. Notice the HTML code is located inside the echo. Changing PHP Text Color Using PHP Inside HTML The same effect is achieved with the following code, which uses PHP inside HTML. In the second example, a single line of PHP is inserted inside the HTML. Although here it is only a line to make the text red in this example, it could be inside a fully formatted HTML page to get any look you want. Types of Formatting Available in HTML It is easy to make text formatting changes to PHP text inside HTML. Although many of these formatting commands have been suspended in Cascading Style Sheets, they all still work in HTML. Some of the text formatting commands that can be used include: Bold - Italic - Underline - Strike-out - or Small - Font size - , replace the ? with a number from 1 to 7, 1 being the smallestCenter text - A complete list of text formatting tags is available. Cite this Article Format mla apa chicago Your Citation Bradley, Angela. "Formatting PHP Text." ThoughtCo, Aug. 27, 2020, thoughtco.com/formatting-your-php-2693945. Bradley, Angela. (2020, August 27). Formatting PHP Text. Retrieved from https://www.thoughtco.com/formatting-your-php-2693945 Bradley, Angela. "Formatting PHP Text." ThoughtCo. https://www.thoughtco.com/formatting-your-php-2693945 (accessed March 27, 2023). copy citation