-3

I have a textarea in which I including outside .php file which contain text.

<textarea class="form-control" rows="15" id="terms" value="" disabled><?php include 'outsidefile.php'; ?></textarea>

The text is appear on textarea perfectly. The file content is

<?php
     echo 'Some text';
?>

Now i want to make style for this Some text for example

<?php
     echo '<p style="font-size: 46px;text-align: center;">Some text</p>';
?>

But when I load the page I see exactly this <p style="font-size: 46px;text-align: center;">Some text</p> instead of text with size 46px and centered.

How can I do this?

Stanly
  • 5
  • 2
  • Check out this Q/A: https://stackoverflow.com/questions/18292609/html-tags-not-being-rendered –  Jul 07 '17 at 05:46

2 Answers2

0

You can't add HTML to textarea values. They are simply an input type, and anything between the <textarea> tags are considered a string, and not parsed as HTML. See this post for making a div editable.

Blue
  • 22,608
  • 7
  • 62
  • 92
  • Oh, didn't knew this. But can I disable this editable div? I want to render text without to be editable? – Stanly Jul 07 '17 at 05:47
  • Don't include it within a ` – Blue Jul 07 '17 at 05:48
  • Oh, yes. I saw that is possible. Because I didn't knew that this is possible with this – Stanly Jul 07 '17 at 05:48
0

You can not use HTML element or it's style into textarea.

Use contenteditable div insted of textarea.

See Example,

CSS

<style type="text/css">
    #likeInput {
        -webkit-appearance: textfield;
        background-color: white;
        -webkit-rtl-ordering: logical;
        user-select: text;
        cursor: auto;
        padding: 1px;
        border-width: 2px;
        border-style: inset;
        border-color: initial;
        border-image: initial;
        text-rendering: auto;
        color: initial;
        letter-spacing: normal;
        word-spacing: normal;
        text-transform: none;
        text-indent: 0px;
        text-shadow: none;
        display: inline-block;
        text-align: start;
        margin: 0em;
        font: 13.3333px Arial;
        border: 1px solid #a9a9a9;
        -webkit-writing-mode: horizontal-tb;
    }
</style>

HTML/PHP

<div contenteditable="true" id="likeInput" disabled="disabled"><?php include 'outsidefile.php'; ?></div>
Jaydeep Mor
  • 1,690
  • 3
  • 21
  • 39