Uncertain of the specific question, I will offer a method to identify (HEX) colors within an HTML element.
Here is the sample HTML code:
<p id="subject">
Here is a color: #fff. Red is #ff0000 while #9ab57d is another color.
</p>
Utilize JavaScript:
$(function() {
var colorMatches = $('#subject').text().match(/#(?:[0-9a-f]{3}){1,2}/gi);
// ['#fff', '#ff0000', '#9ab57d']
$.each(colorMatches, function(index, value) {
// `value` represents each identified color...
});
});
(See Demo)
Update:
Demo showcasing the usage of colors:
HTML:
<p id="subject">
Here is a color: #fff. Red is #ff0000 while #9ab57d is another color.
</p>
<ol id="result"></ol>
JS:
$(function() {
var colorMatches = $('#subject').text().match(/#(?:[0-9a-f]{3}){1,2}/gi),
$resultList = $('#result');
$.each(colorMatches, function(index, value) {
$('<li />').text(value).css('background-color', value).appendTo($resultList);
});
});
Second Update:
As per suggestions, replacing inline styles (view demo):
HTML:
<p id="subject">
Nous obtenons les 2 couleurs suivantes : #40464f & #0f131a
</p>
JS:
$(function() {
var $subjectElement = $('#subject'),
content = $subjectElement.html();
content = content.replace(/#(?:[0-9a-f]{3}){1,2}/gim, "<span style=\"background-color: $&;\">$&</span>");
$subjectElement.html(content);
});