1

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.

berkes
  • 26,996
  • 27
  • 115
  • 206
Lucky13
  • 11,393
  • 7
  • 25
  • 36
  • what do you mean "without changing the code"? what is "the code"? – xaxxon Feb 03 '11 at 08:28
  • @Xaxxon, he means the source HTML. @Nakshathra, can you show us your HTML that you cannot change? – Kyle Feb 03 '11 at 08:29
  • AFAIK, CSS can't. unless you put a `
    ` or `

    ` tag dynamically, may be using JS, at the place. Ideally, "Europcar" should be under a separate tag like `h1, h2, div etc` as the format dictates.
    – Nishant Feb 03 '11 at 08:31
  • you ask 13 questions for that you get more than 30 answer, none of them are accepted to you!!!?? Please consider some answer to accept..... – enam Apr 06 '11 at 16:29

4 Answers4

4

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.

Kissaki
  • 8,810
  • 5
  • 40
  • 42
3

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

Community
  • 1
  • 1
enam
  • 1,179
  • 1
  • 10
  • 24
2

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.

acme
  • 14,654
  • 7
  • 75
  • 109
2

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

gearsdigital
  • 13,915
  • 6
  • 44
  • 73