StackOverflow StackOverflow - 1 day ago 4
C# Question

Add CSS to static text & not dynamic in one element

I would like to add styles to only the static text
E.G

"Hello Foo"

How Hello is created

Node("td#NameID").Add(
Hello
)


Foo comes to the view through the users input using Jquery by getting the element by ID & placeing that next to Hello.

I want to have "Hello" bold, but am not sure how to do so. When I add a CSS to the ID or the class it makes the whole line bold, not just the word "Hello"

Let me know if you have questions.

Answer

Try wrapping Hello in a span and using css like

#NameID span {
  font-weight: bold;
}

As long as the Foo is outside of the span, only the "Hello" will be in bold.

Comments