search

Home  >  Q&A  >  body text

How to create a group box

I found the code for creating the group box:

<fieldset>
    <legend>Title</legend>
</fieldset>

It is said to create the following group boxes at runtime:

When I run it in Visual Studio Code, it looks like this:

The borders are barely visible and the text appears in the wrong place. Did I do something wrong?

P粉818125805P粉818125805252 days ago385

reply all(1)I'll reply

  • P粉052686710

    P粉0526867102024-03-22 15:27:14

    The problem is that all browsers have different default styles. Your unusual.

    I copied some user agent stylesheets from MacOS Chrome109

    fieldset {
        display: block;
        margin-inline-start: 2px;
        margin-inline-end: 2px;
        padding-block-start: 0.35em;
        padding-inline-start: 0.75em;
        padding-inline-end: 0.75em;
        padding-block-end: 0.625em;
        min-inline-size: min-content;
        border-width: 2px;
        border-style: groove;
        border-color: rgb(192, 192, 192);
        border-image: initial;
    }
    
    legend {
        display: block;
        padding-inline-start: 2px;
        padding-inline-end: 2px;
        border-width: initial;
        border-style: none;
        border-color: initial;
        border-image: initial;
    }
    Title

    reply
    0
  • Cancelreply