When creating a header, does the border width tag go inside the <h1>
tag or in a separate tag? I'm trying to make the border wrap around the header text in the middle of the page, instead of stretching to either side.
Asked
Active
Viewed 189 times
-1

Ian Campbell
- 23,484
- 14
- 36
- 57

kyre white
- 1
- 5
-
Is it possible for you to provide your code? Would be easier to know how you are trying to achieve what with the current code. Also, take less time re-writing everything by hand for us while trying to help out. – Lith Dec 19 '20 at 03:55
-
This post appears to be [off-topic](http://stackoverflow.com/help/on-topic) as per *Questions that lack sufficient information to diagnose the problem.* Please edit your post accordingly to add sufficient detail so that people may help you. – Adhitya Dec 19 '20 at 04:01
2 Answers
2
Use padding and display:inline-block; on a span tag.
OR do it like this:
span {
padding: 10px;
border: 5px solid black;
display: inline-block;
}
<span>Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? Is this long enough? </span>

react_or_angluar
- 1,568
- 2
- 13
- 20
-
1if my header was one sentence of 28 letters, centered, how many pixels would the border be in h/w and where in my code do i place the {span} tag as above? – kyre white Dec 19 '20 at 04:43
-
Why not use em? Show me what you mean here. http://jsfiddle.net/PEvL8/ Don't you have to know the size of this screen and all that? https://stackoverflow.com/questions/3437786/get-the-size-of-the-screen-current-web-page-and-browser-window – react_or_angluar Dec 19 '20 at 04:46
-
Here is how you can calculate the text width https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript – react_or_angluar Dec 19 '20 at 04:52
0
You can set the border-width like this:
<h1 style="border: 4px solid black;"></h1>
That is, if it's the header that is having the border styling, if it's another tag then you make that change there instead.

Robin
- 1