Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color the First word of Sentence CSS [duplicate]

Tags:

html

css

I was trying to color just first WORD of sentence

<div class="logoS">Title Of The Page</div>

CSS which am using is

.logoS{
    padding: 0px;
    float: left;
    font-family: 'Open Sans', Helvetica, Arial, sans-serif;
    color: white;
    border:solid 1px black;
    font-weight: bold;
    font-size: 22px;
}

.logoS::nth-word(1) {
  margin-right: 20px;
}

i just want to color "TITLE" not other words, any solution

like image 369
Juanid Farooq Avatar asked Aug 29 '14 03:08

Juanid Farooq


4 Answers

Try this, hope this will help .

.logoS:before {
  color: red;
  content: "Title ";
}
<div class="logoS">Of The Page</div>
like image 130
user3835327 Avatar answered Oct 20 '22 08:10

user3835327


The code

<div class="logoS"><span id="first">Title</span> Of The Page</div>

.logoS{
    padding: 0px;
    float: left;
    font-family: 'Open Sans', Helvetica, Arial, sans-serif;
    color: blue;
    border:solid 1px black;
    font-weight: bold;
    font-size: 22px;
}

#first {
  margin-right: 20px;
    color: red;
}
like image 37
Joshua Howard Avatar answered Oct 20 '22 10:10

Joshua Howard


Use a span with preferred style for the first word like

<div class="logoS"><span class="spanstyle">Title </span>Of The Page</div>

// CSS
.spanstyle {
  color:blue;
}

Check this link . There is :first-letter and :first-line, but no :first-word.

like image 26
Jenz Avatar answered Oct 20 '22 10:10

Jenz


Use a span tag, this way it won't start a new line. For example:

<div class="logoS"><span id="title">Title</span> Of The Page</div>

and then in your css just add:

#title{
color: red
}

Hope this works!

like image 1
Ian Wise Avatar answered Oct 20 '22 08:10

Ian Wise