Latest web development tutorials

Screen width attribute

Screen Object Reference Screen objects

Definition and Usage

width attribute declares the browser screen display width, in pixels.

grammar

screen.width


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support width attribute


Examples

Examples

Returns the total width of your screen:

<script>

document.write("总宽度: " + screen.width);

</script>

Examples of the above output:


try it"


Examples s

More examples

This example contains all screen attributes


Screen Object Reference Screen objects