HTML - attributes - width

revision:


Content

"width" attribute : specifies the width of an element syntax some examples


"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

top

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

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


some examples

top
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>
                




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>