Qix-/color

How can I convert #FF00 to red(#FF0000)? #190

maltoze posted onGitHub

Currently it converts #FF00 to #FFFF00.

> const color = require('color')
> color('#FF00').hex()
'#FFFF00'

Is there any way to convert from #FF00 to #FF0000? Thanks.


No, because that doesn't make any sense. #FF00 equates to #FFFF0000 (alpha of 0) as per the CSS specification. I think you're misunderstanding how hex color shorthand works 😉

Shorthand for red is #F00.

posted by Qix- over 4 years ago
var worldString = 'Hello, world';

console.log(worldString.fontcolor('red') +  ' is red in this line');
// '<font color="red">Hello, world</font> is red in this line'

console.log(worldString.fontcolor('FF00') + ' is red in hexadecimal in this line');
// '<font color="FF00">Hello, world</font> is red in hexadecimal in this line'

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fontcolor#Using_fontcolor

@Qix- But why is FF00 here in red?

posted by maltoze over 4 years ago

That is the <font> tag that hasn't been used in decades. Its color semantics are not governed by CSS. What are you trying to do? Don't use the font tag...

posted by Qix- over 4 years ago

I'm parsing a old website which has a lot of font tag...

posted by maltoze over 4 years ago

Fund this Issue

$0.00
Funded

Pull requests