<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Santa Clarita TV Mounting</title>
    <description>The latest articles on DEV Community by Santa Clarita TV Mounting (@santaclaritatvmounting).</description>
    <link>https://dev.to/santaclaritatvmounting</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4258090%2Fb248f859-541e-4d3a-94d7-d62700776cf4.png</url>
      <title>DEV Community: Santa Clarita TV Mounting</title>
      <link>https://dev.to/santaclaritatvmounting</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/santaclaritatvmounting"/>
    <language>en</language>
    <item>
      <title>The math behind a TV mounting height calculator (vanilla JS)</title>
      <dc:creator>Santa Clarita TV Mounting</dc:creator>
      <pubDate>Sun, 22 Nov 2026 00:13:33 +0000</pubDate>
      <link>https://dev.to/santaclaritatvmounting/the-math-behind-a-tv-mounting-height-calculator-vanilla-js-5cf1</link>
      <guid>https://dev.to/santaclaritatvmounting/the-math-behind-a-tv-mounting-height-calculator-vanilla-js-5cf1</guid>
      <description>&lt;p&gt;"How high should I mount my TV?" sounds like a question for a tape measure, but it is really a small geometry problem. I wrote a calculator for it in plain JavaScript: no framework, no dependencies, one file that runs in the browser and in Node. This post walks through the math and the code, so you can reuse the formulas in your own projects.&lt;/p&gt;

&lt;p&gt;The calculator takes four inputs: the TV's diagonal, how far you sit from it, your seated eye height, and (optionally) the height of a fireplace mantel. It returns the height of the screen's center, its top and bottom edges, the vertical viewing angle, a recommended size range for your distance and, over a fireplace, how much tilt you need.&lt;/p&gt;

&lt;p&gt;You can &lt;a href="https://codepen.io/santaclaritatvmounting/pen/mymwvxy" rel="noopener noreferrer"&gt;try the calculator on CodePen&lt;/a&gt; while you read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: width and height from the diagonal
&lt;/h2&gt;

&lt;p&gt;TVs are sold by their diagonal, but for mounting you need the physical height of the panel. For a 16:9 screen the diagonal is the hypotenuse of a right triangle with sides 16 and 9 units, so it is &lt;code&gt;sqrt(16² + 9²) = sqrt(337)&lt;/code&gt; units long. Scale that triangle and you get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="no"&gt;ASPECT_W&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="no"&gt;ASPECT_H&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="no"&gt;ASPECT_DIAG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;ASPECT_W&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;ASPECT_W&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="no"&gt;ASPECT_H&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;ASPECT_H&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// sqrt(337)&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;screenSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diagonal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;diagonal&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;ASPECT_W&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;ASPECT_DIAG&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;diagonal&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;ASPECT_H&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;ASPECT_DIAG&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A 65" TV comes out at 56.65" wide and 31.87" tall. (The real panel with its bezel is a little larger, but the screen area is what your eyes care about.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: put the center at eye level
&lt;/h2&gt;

&lt;p&gt;The usual ergonomic rule is that the center of the screen should sit at your seated eye height, so you look straight ahead instead of up. On a typical sofa that is about 42" from the floor, which is the default:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="no"&gt;DEFAULTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;eyeHeight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;        &lt;span class="c1"&gt;// seated eye height, in (typical sofa)&lt;/span&gt;
  &lt;span class="n"&gt;maxComfortAngle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// degrees above eye level to the screen centre&lt;/span&gt;
  &lt;span class="n"&gt;mantelClearance&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;// gap between mantel top and TV bottom edge, in&lt;/span&gt;
  &lt;span class="n"&gt;tiltMountMax&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="c1"&gt;// typical tilting mount range, degrees&lt;/span&gt;
  &lt;span class="n"&gt;smpteFov&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="c1"&gt;// SMPTE EG-18 minimum horizontal field of view&lt;/span&gt;
  &lt;span class="n"&gt;thxFov&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;            &lt;span class="c1"&gt;// THX recommended horizontal field of view&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you know the center, the edges are half the screen height above and below it. For the 65" TV: center 42", bottom 26.1", top 57.9". Notice the bottom edge: people usually guess "about 4 feet for the bottom", which puts the center far above eye level.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: the vertical viewing angle
&lt;/h2&gt;

&lt;p&gt;The center can't always sit at eye level (more on fireplaces below), so the calculator checks how far up you have to look. That is a plain right triangle again: the rise is the center height minus your eye height, the run is your seating distance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="no"&gt;DEG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PI&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;180&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/** Vertical angle (deg) from the eye to a point `heightIn` high, `distanceIn` away. */&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;verticalAngle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heightIn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;eyeHeightIn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;distanceIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;atan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heightIn&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;eyeHeightIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;distanceIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;DEG&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is compared to a 15° comfort limit. Up to that, an upward gaze is fine for a movie night; above it you can feel it in your neck after an hour. Using &lt;code&gt;Math.atan&lt;/code&gt; of rise over run (rather than a lookup table) means the check works for any distance and any height, and it stays correct when the inputs come in as strings from form fields, because &lt;code&gt;calculate()&lt;/code&gt; runs everything through &lt;code&gt;Number()&lt;/code&gt; and validates the ranges first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: what size suits your distance (SMPTE and THX)
&lt;/h2&gt;

&lt;p&gt;The same trigonometry answers "how big should the TV be?". Two common reference points are the SMPTE guideline that the screen should fill at least a 30° horizontal field of view, and the THX recommendation of about 40°. Given a field of view and a distance, the screen width is &lt;code&gt;2 · distance · tan(fov / 2)&lt;/code&gt;. Convert that width back to a diagonal with the 16:9 ratio:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;diagonalForFov&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;distanceIn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fovDeg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;distanceIn&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fovDeg&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;DEG&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="no"&gt;ASPECT_DIAG&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;ASPECT_W&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fovForDiagonal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diagonal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;distanceIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;screenSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diagonal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;atan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;distanceIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;DEG&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At 9 feet (108") that gives a range of roughly 66" (SMPTE) to 90" (THX). A 65" TV at 9 feet covers about 29°, so the tool says it is just under the range: fine for everyday TV, less immersive for films. The two functions are inverses of each other, which turns out to be handy for testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: the fireplace case
&lt;/h2&gt;

&lt;p&gt;Mounting over a fireplace is where the math gets interesting, because the mantel sets a hard floor. The bottom edge must clear the mantel by some gap (6" by default, to leave room for heat and decor), so the lowest possible center is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;minCenter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mantel&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;clearance&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;minCenter&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;center&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;center&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;minCenter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;limitedByMantel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take a 54" mantel and the same 65" TV at 9 feet. The center jumps from 42" to 75.9", and the viewing angle becomes 17.4°, over the 15° limit. The calculator then works out a tilt: pointing the screen at your eyes means tilting it down by the same angle as the line of sight. It caps the suggestion at the 15° that a typical tilting mount offers, and when the angle is over the comfort limit it recommends a pull-down (mantel) mount, which lowers the TV to eye level while you watch. Move the sofa back to 12 feet and the angle drops to 13.3°: a 13° tilt is enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  A note on the tests
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;script.js&lt;/code&gt; exports its API with &lt;code&gt;if (typeof module !== 'undefined' &amp;amp;&amp;amp; module.exports) module.exports = api;&lt;/code&gt;, so the same file loads in Node. &lt;code&gt;tests.js&lt;/code&gt; uses only the built-in &lt;code&gt;assert&lt;/code&gt; module and runs with &lt;code&gt;node tests.js&lt;/code&gt;, no test framework. The 17 tests check things you can verify by hand: a 65" panel is 56.65" × 31.87"; &lt;code&gt;Math.hypot(width, height)&lt;/code&gt; equals the diagonal and the ratio is 16/9 for several sizes; SMPTE at 9 feet is about 66.4" and THX about 90.2"; &lt;code&gt;fovForDiagonal&lt;/code&gt; inverts &lt;code&gt;diagonalForFov&lt;/code&gt;; a low mantel never pushes the TV below eye level; an angle exactly at 15° passes while a slightly closer seat fails; and bad or empty form input returns errors instead of &lt;code&gt;NaN&lt;/code&gt;. The exact-limit test pins down the comparison: the check is &lt;code&gt;angleCenter &amp;lt;= 15&lt;/code&gt;, not &lt;code&gt;&amp;lt;&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The whole thing is about 270 lines including the UI, and the math fits in a few small pure functions: &lt;code&gt;screenSize&lt;/code&gt;, &lt;code&gt;verticalAngle&lt;/code&gt;, &lt;code&gt;diagonalForFov&lt;/code&gt; and &lt;code&gt;fovForDiagonal&lt;/code&gt;. Keeping those separate from the DOM code is what makes the tool easy to test and easy to port.&lt;/p&gt;

&lt;p&gt;I built this calculator for &lt;a href="https://santaclaritatvmounting.com/" rel="noopener noreferrer"&gt;Santa Clarita TV Mounting&lt;/a&gt;, where people often ask how high a TV should go, especially over a fireplace. If you build something similar, the formulas above work just as well for monitors, projectors or any 16:9 screen; change &lt;code&gt;ASPECT_W&lt;/code&gt; and &lt;code&gt;ASPECT_H&lt;/code&gt; for other ratios.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
