Change word style next to via css

Asked

Viewed 538 times

-1

I received a track to do in the layout of a site and would like to know if it could reproduce the effect via css.

For example I have the phrase -> Hello I am a text.
Would you like to always be able to bold the last word of the text. Is it possible to do this with css? If not which would be the best way?

Faixa de exemplo

1 answer

0


Of course it is possible there are several ways to it, I will post some:

using the B tag, for example your html text -> <h1> meu texto <b>aqui!</b></h1> the text here! will be in bold

but as good practices the ideal is to use css creating a class:

The "font-Weight" property, which is the "Bold".

Bold equals our famous tag , to simply bold an excerpt. The syntax is:

font-weight: bold;

The bold basically serves to highlight an excerpt of a text. For example, to make the following sentence bold:

"CSS is a really important style language in website creation."

We can use the following code snippet, directly on the tag :

"CSS is a style language <span style="font-weight: bold">realmente</span> important in the creation of websites."

Or by creating a css class and then assigning it to an element

.negrito {
 font-weight: bold;
}

<span class='negrito'>oi</span>
  • Thanks Julio :D It is that so the title that I am doing it is generated automatically through a variable coming from the system. That’s why I wanted to get the last word, because the last one should always be bold. You think it gives ?

  • da yes, there is no way to generate this text with tags?

  • which Voce technology is using for back-end

  • Is being generated via php

  • I was able to solve via JS (Jquery). So here -> In HTML <H1 class="lastWord">Single Track</H1> In css . lastWord{ font-Weight: Lighter; } . wordbold{ font-Weight: Bold; } In the JS $(".lastWord"). html(Function(){ var text= $(this).text().Trim().split(" "); var last = text.pop(); Return text.Join(" ") + (text.length > 0 ? " <class='wordbold'>" + last + "</>" : last); }); &#span;#Xa; And I can apply your first explanation by changing his style. But also thinking about semantics.

  • yes, it was with that same that I would post the solution

  • good bro! Great kidney logic

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.