You need to set the border for the element (in my case, the TEST text) to its length, not the length of the parent.

<div id="topMenu"> <div class="firstTopMenuItem">TEST</div> </div> #topMenu { height: 80px; margin: 0 auto; background-color: #fff; width: 980px; min-width: 980px; border: 1px solid #f00; } .firstTopMenuItem { width: auto; font-family: Tahoma; font-size: 15px; color: #000; border: 1px solid #000; margin-left: 15px; margin-top: 25px; } 

Screenshot: http://clip2net.com/clip/m0/a8ff2-clip-4kb.png?nocache=1

    1 answer 1

    So after all, you have set the border in the length of the element. Just the length of the element in the length of the parent: width: auto;

    Update

    For a block element - almost only statically. You can float'ami or absolutes, but do not abuse these, as long as there is no understanding how html and css work.

    Make the element lowercase - and there will be happiness. display: inline or display: inline-block;

    • In that case, how can I set the width equal to my text? Only statically? - niks123123
    • Updated the answer - Nasty Pacman