The length of the towel bar is 9.5 inches.
Explanation
Suppose, the length of the towel bar is [tex]x[/tex] inches.
The distance from each end of the towel bar to the end of the door is 9 inches. So, the total width of the door will be: [tex][x+(9*2)] = (x+18)inches[/tex]
Given that, the width of the door is [tex]27\frac{1}{2}[/tex] inches or 27.5 inches. So, the equation will be........
[tex]x+18=27.5\\ \\ x=27.5-18= 9.5[/tex]
Thus, the length of the towel bar will be 9.5 inches.