0

I am new to Html & CSS. I want a heading which contains text like "Women safty". I want to warp the heading text with border. But when I apply border to text the border covers all the area in the width both left and right.I just want to add border around text only and the text needs to be in center.enter image description hereenter image description here

4 Answers4

1

Here is your text in HTML:

 <p>Women Safety</p>

In your CSS create your border with this command:

p.solid {border-style: solid; display:inline}
Dennis Kozevnikoff
  • 2,078
  • 3
  • 19
  • 29
1
<p style="text-align: center;">
    <span style="border: 1px solid red;display: inline-block;">Women safty</span>
</p>
1

Using a span

HTML

<span>Women safty</span>

CSS

body {
    text-align: center;
}
span {
    border: solid;
}

Result

enter image description here

Using a div, h1 and p

HTML

<h1>Women safty</h1><br /><br />
<div>Women safty</div><br /><br />
<p>Women safty</p><br /><br />

CSS

body {
    text-align: center;
}
h1 {
    border: solid;
    display: inline;
}
div {
    border: solid;
    display: inline;
}
p {
    border: solid;
    display: inline;
}

Result

enter image description here

cerebrus6
  • 86
  • 8
  • 1
    Tnx bro it worked. Both the method worked. Can I able to use

    tag after span tag .Tnx a lot @cerebrus6

    – NaVeEd IbRaHiM Jul 09 '20 at 18:09
  • Yes you can. Also, a thing to take note. Even if span, div, p and h1 have almost the same effect in word wrapping the text, if you want to adjust the width manually, you cannot do it if you use span. But if you use div, p and h1, you can adjust them easily using width and height in css. Have a wonderful programming journey @NaVeEdIbRaHiM. – cerebrus6 Jul 10 '20 at 07:03
0

Try This.

#test {
  border: solid; padding: 0.5%; display: inline;
}
<p id="test">Women Safety</p>
ahsan
  • 1,409
  • 8
  • 11