I have a html page. I want to make sure that if I resize the window, the contents also get resized so as not to get scrolled horizontally. What can I do?
Don't use absolute widths and heights. Set all values to percentages instead. Thats pretty much all you can do.
Minimize your use of static widths. The browser will do most of the work for you.
Look up liquid layouts in google. You'll get lots of ideas, templates and sample CSS to use
Avoid use of absolute values.
Eg: try to use width="50%" instead of width="167px"
Fluid Grids from A List Apart is a good example of how to design a fluid layout, even when using grids.
Avoid px
and pt
(and cm
, in
, mm
, pc
and ex
) in CSS. Try to use em
and %
.
Besides many fluid layout techniques mentioned in other answers, there are CSS3 Media Queries (and "Switchy McLayout" script that works in old browsers) that allow you to dynamically apply different CSS rules (even completely different layout) depending on screen resolution or window size.