One of the best ways to fix the gap between a mattress and a headboard is to block it by using mattress wedges. These products are made with foam and should be placed between the headboard and mattress/box spring to eliminate the gap. Repositioning your headboard and frame may also help fill the extra space. Adjust the frame to be wider than the headboard by unhooking it in the middle and widening it. Then push the frame back against the headboard. Lastly, add the box spring and mattress and push them against the headboard as well. Sometimes making these small adjustments to your items keeps your headboard in alignment.