HTML - attributes - w....

revision:


Content

"width" attribute : specifies the width of an element "wrap" attribute : specifies how text is wrapped in textarea


"width" attribute : specifies the width of an element

top

The width attribute specifies the width of the element, in pixels.

The width attribute can be used on the following elements: <canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video>.

For input elements, the width attribute is used only with <input type="image">.

syntax

<element width="pixels"></element>

pixels: the width in pixels (e.g. width="100")

some examples

example
Your browser does not support the HTML5 canvas tag.

codes:

                    <canvas id="myCanvas" width="200" height="200" style="margin-left:3vw;border:1px solid">
                        Your browser does not support the HTML5 canvas tag.
                    </canvas>
                    <script>
                        var c = document.getElementById("myCanvas");
                        var ctx = c.getContext("2d");
                        ctx.fillStyle = "#92B901";
                        ctx.fillRect(50, 50, 100, 100);
                    </script>
                

example




codes:

                    <form style="margin-left:3vw;" action="/action_page.php">
                        <label for="fname">First name:</label>
                        <input type="text" id="fname" name="fname"><br><br>
                        <label for="lname">Last name:</label>
                        <input type="text" id="lname" name="lname"><br><br>
                        <input type="image" src="../pics/submit.gif" alt="Submit" width="24" height="24">                             
                    </form>
                

"wrap" attribute : specifies how text is wrapped in textarea

top

The wrap attribute specifies how the text in a text area is to be wrapped when submitted in a form. The wrap attribute can be applied on the following HTML element: <textarea>.

syntax

<textarea wrap="soft|hard"></textarea>

soft: the text in the textarea is not wrapped when submitted in a form. This is default.
hard: the text in the textarea is wrapped (contains newlines) when submitted in a form. When "hard" is used, the cols attribute must be specified.

some examples

example

codes:

                    <form style="margin-left:3vw;" action="/action_page.php">
                        <textarea rows="3" cols="20" name="usrtxt" wrap="hard">In various places on my website you will 
                        find free Web-building tutorials.
                        <input type="submit">
                    </form>
                

example

codes:

                    <textarea style="margin-left:3vw;" id="myId"  rows="3" cols="20" name="newText" wrap="soft">
                    This text is wrapped in the text area field.</textarea>                               
                    <br>
                    <button style="margin-left:3vw;" onclick="submitText()">Submit</button>