Showing that $\lim_{h\rightarrow0}\max_{y\in[x,x+h]}f(y)=f(x)$

Let $f:[a,b]\rightarrow\mathbb{R}$ be continuous and $x\in[a,b]$. I would like to show that $$\lim_{h\rightarrow 0}\max_{y\in[x,x+h]} f(y)=f(x).$$

Since for $h>0$ such that $x+h\in[a,b]$, we get $f(x)\leq\max_{y\in[x,x+h]}f(y)$, we can conclude that $$f(x)\leq\lim_{h\rightarrow 0}\max_{y\in[x,x+h]} f(y).$$

I can't figure out how to show $\lim_{h\rightarrow 0}\max_{y\in[x,x+h]} f(y)\leq f(x)$. Any hints?


Take $\epsilon \gt 0$. Then by continuity of $f$ at $x$, it exists $\delta \gt 0$ such that for $x \le y \le x +\delta$ we have

$$f(y) \le f(x) +\epsilon.$$

This implies that

$$\max\limits_{y \in [x,x+h]} f(y) \lt f(x)+\epsilon$$ for all $0 \le h \le \delta$. As this is true for all $\epsilon \gt 0$, we get the desired inequality.