0

How to center an ELEMENT that has been set to HALF the WIDTH of it's parent.

Hello, everyone, so, I have been struggling with this one. 1.) I was just experimenting with creating an element, say a <header>. 2.) Now, I want this header to be at the TOP and CENTER of my page. 3.) But I want that header to be 50% of the parent element <body>. 4.) So, how do we go about centering ANY element (DIV, P, HEADER) whose WIDTH has been set a certain percentage of it's parent <body>? 5.) The percentage of the element can be anything like say 40% or 65% of the <body> which is 100%. So, how would I go about centering it perfectly at the TOP and CENTER of my page?

5th Jul 2024, 5:34 AM
M Isaac Torres L
M Isaac Torres L - avatar
1 Resposta
+ 3
Share your code attempt.
5th Jul 2024, 7:19 AM
Chris Coder
Chris Coder - avatar