Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to calculate the width of an HTML element based on the window size.

Here's what I have. These width values (first value) accurately match with the width the HTML element must be (second value). However I need to get a formula for this to be able to set the width of the HTML correctly according to any possible window size.

window width / HTML element width

  • 1663 = 1916
  • 1221 = 1692
  • 1119 = 1641
  • 1038 = 1602
  • 630 = 1396

  • 1500 = ????

  • 1400 = ????
  • 2000 = ????

I've been staring at this four hours but I just can't wrap my head around it..

Any help would be appreciated.

Thanks in advance, Roel

share|cite|improve this question
All of your equations are false. $1663$ is not the same as $1916$", and the $=$ sign does not mean "corresponds to, in some unspecified context-dependent way". – Henning Makholm Apr 26 '12 at 12:22

Linear regression gives: $m=0.5030755166$ $c=1078.8117490$ with $R^2=0.9999778405$. This gives the desired values as

  • 630 1396
  • 1500 1833
  • 1400 1783
  • 2000 2085
share|cite|improve this answer
Thanks Shitikanth, glad someone knows how to do this :) .. But which formula can I use to get the element width for any window width my users may be using?? How can I implement this programmatically??? - So I mean: x (element width) = <formula> Thanks! – R_K Apr 26 '12 at 14:57
y= mx+c with m and c given above (x is the window width and y is the HTML window width) – Shitikanth Apr 26 '12 at 15:56
I'm sorry I'm a complete mathematics noob :P .. What does mx mean? Do i have to multiply m with x before adding it to c? --thanks again – R_K Apr 26 '12 at 16:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.