HTML event attribute onresize

The onresize attribute event is triggered when the browser window is resized.

What's new in HTML5

The onresize attribute is new in HTML5.


<element onresize="script or Javascript function name">

Supported Tags


Browser compatibility

onresize Yes Yes Yes Yes Yes


<!DOCTYPE html>
<!-- ww w . ja  va 2s.  co  m-->
<body onresize="myFunction()">

<p>resize the browser window.</p>

function myFunction() {


Click to view the demo