Hi,
I have a h1 tag and would like each work to break onto a new line. Apart from wrapping each word in a span and giving it a display: block;, is there another way to do this?
Thanks!
Hi,
I have a h1 tag and would like each work to break onto a new line. Apart from wrapping each word in a span and giving it a display: block;, is there another way to do this?
Thanks!
Hi there toolman,
this should get the job done…
<h1>
Make<br>
each<br>
word<br>
in<br>
a<br>
heading<br>
display<br>
as<br>
a<br>
block
</h1>
coothead
Many thanks, I will use that ![]()
I wondered if there was a way with CSS?
You could try word-spacing:
h1 {
width: 5em;
text-align: center; /* if you like */
word-spacing: 5em;
}
Hi there toolman,
if you prefer to use @Erik_J’s CSS method,
it might be prudent to add…
word-break: break-all;
…to the code, for words that may overflow the
confines of a fixed width. ![]()
coothead
Good point, but not necessary if the goal is to break each word to a new line. As you mention, the text would overflow the fixed width.
Though the center align would need a sufficient width to truly center.
Why not just this:
h1{display:table;width:1%}
Or did I miss something?
edit: Yes I did lol. If the word is long then two words will fill the space.
Please Ignore this post ![]()
Edit Edit: Added word spacing:100vw and now it seems to work ![]()
I am obviously biased here, but I see
the solution to this problem as…
HTML: 1 , CSS: 0
[edit]
@PaulOB’s Edit Edit does of course mean
that I will have to change the result to…
HTML: 1 , CSS: 1 ![]()
[/edit]
coothead
You forgot to count my version!
HTML: 1, CSS:2
FTFY ![]()
Sorry about that Eric. ![]()
Unfortunately, due to a reduction in my neural
pathways, I often forget all sorts of stuff. ![]()
Oh my gosh, where am I? ![]()
cohoteda
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.