Creating custom header extending Magento blank in Magento 2
<p>I am trying to create a theme with Magento Blank as parent in Magento 2 but I can't figure it out how to change the header with a custom one.</p>

<p>I first remove header.container from magento blank and create my container but it is created inside page-wrapper between main-content and footer and I can't make it go before main-content.</p>

<p>This is my layout.xml:</p>

<pre><code>&lt;page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"&gt;
    &lt;body&gt;
        &lt;referenceBlock name="register-link" remove="true" /&gt;
        &lt;referenceBlock name="authorization-link" remove="true" /&gt;
        &lt;referenceBlock name="wish-list-link" remove="true" /&gt;
        &lt;referenceBlock name="my-account-link" remove="true" /&gt;
        &lt;referenceBlock name="top.links" remove="true" /&gt;
        &lt;referenceBlock name="header.panel.wrapper" remove="true" /&gt;
        &lt;referenceBlock name="header.container" remove="true" /&gt;

        &lt;referenceContainer name="page.wrapper"&gt;
            &lt;container name="custom.header" htmlClass="headerSection" htmlTag="div"&gt;
                &lt;block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::html/sections.phtml"&gt;

                &lt;/block&gt;
            &lt;/container&gt;
        &lt;/referenceContainer&gt;

    &lt;/body&gt;
&lt;/page&gt;
</code></pre>

<p>And this is how it looks the HTML:</p>

<p><a href="https://i.stack.imgur.com/5WYE3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5WYE3.png" alt="enter image description here"></a></p>