I wish to centre (both horizontally and vertically) an element of any width/height within another other element and/or within the browser window.I would ideally like a solution that works whether I'm trying to centre content within an element on the page or within the browser window itself.I realise other questions address various aspects of what I'm attempting to do, but the answers I have read thus far have been unsatisfactory for me.I am looking for a solution that:
- uses purely HTML + CSS (I see there some JS solutions)
- doesn't use tables (or divs with "display: table" etc property)
- is not reliant on fixing the height of the centred element (I see some solutions work with fixed height + negative top margins)
- will work for centring an element within another a div or within the entire browser window