开发者

How to change colour of a certain word in an HTML file in a Java code?

开发者 https://www.devze.com 2023-02-22 12:39 出处:网络
In the pre-existing code, the HTML file background colour has been set like this: file+=\"<table width=\\\"95%\\\" align=\\\"center\\\" style=\\\"background : #\"+

In the pre-existing code, the HTML file background colour has been set like this:

 file+="<table width=\"95%\" align=\"center\" style=\"background : #"+
                HTML_REPORT_COLOR_2+"; border : 1px solid #000000\">";

file+="Wrong colour for driver has been chosen . The correct tag is Green";
                file+="<br/><br开发者_StackOverflow/>";

I want to change the wrong word which is presently in black to red. The right way to go about using the fonts tag, but how do I use it here, as this is a Java code. I tried feeding it to the file variable, but "#" is giving me an error.


Current

Wrap the word "Wrong" in a span tag, like this:

<span class="error">Wrong</span>

If you have access to the CSS of the document, add this declaration:

.error{
    color: #FF0000;
}

If you don't have access to the CSS, make the span element look like this, instead:

<span style="color: #FF0000;">Wrong</span>

Previous

If I'm correctly understanding what you're trying to do, you need to change the hexadecimal value of HTML_REPORT_COLOR_2 from 000000 or 000 to FF0000 or F00.

That should be the solution, unless I'm mis-understanding your problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消