Lucky13
Lucky13

Reputation: 11493

css property for breaking sentences

I've a text "Europcar The Quickest Way From Runway To Road".I want to display this like

Europcar
The Quickest Way From Runway To Road

how to get in this format using CSS without changing the HTML code.

Upvotes: 1

Views: 785

Answers (4)

enam
enam

Reputation: 1177

What you are looking for is a pseudoclass that doesn't exist. There is :first-letter and :first-line, but no :first-word.

Here is the topic you can check CSS to increase size of first word

Upvotes: 3

gearsdigital
gearsdigital

Reputation: 14225

You can do it with Javascript but not width pure CSS. http://www.dynamicsitesolutions.com/javascript/first-word-selector/

Upvotes: 2

acme
acme

Reputation: 14866

If the original string has now html tags like a span or something else, it's not possible with pure CSS. CSS offers only the pseudo selectors :first-line and :first-letter but not :first-word what you need. In other words, you can't select the first word of a text with CSS to insert a line-break :after it.

Upvotes: 2

Kissaki
Kissaki

Reputation: 9247

You can’t really in a nice way.

The only way would be to add (e.g. with :after) another block element, position it to where you don’t want the text and make the text float around any top-elements.

With nothing to style there CSS is not the right thing. CSS is for styling, the missing newline is missing some markup however.

Upvotes: 4

Related Questions