Skip to content
Advertisement

How do you style input that PHP posted with a CSS selector?

I want to create a webpage that posts onto itself text inserted into an input field, using CSS to stylize said text once it becomes part of the page. However, I don’t know how to refer to it with a CSS selector. I’ve done what every HTML-newb tries when encountering a problem and wrapped both the form code and PHP statement in classified DIVs, however, the computer visibly doesn’t know what I’m trying to address. Likewise, wrapping the PHP statement in paragraph tags doesn’t apply to it the stylization said tags are associated with.

For Reference, Form & PHP Code:

<form method = "post">
<textarea name="input"></textarea>
<input type="submit">
</form>

<?php echo $_POST['input'];?>

My apologies if the solution to this is obvious; I can’t find information addressing it.

Advertisement

Answer

you could inline style it or with a class.

<form method = "post">
  <textarea name="input"></textarea>
  <input type="submit" name="submit">
</form>
<div class="input-value">
<?php 
if(isset($_POST['submit])) {
  echo $_POST['input'];
}
?>
</div>

use .input-value class in css

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement