While editing some old ColdFusion code I found a <td> which has a bgcolor property. The value of it was ##89969E. I copied the code to a HTML file and found out the color was different in ColdFusion.
Now, i noticed the double #, so i removed one and the color was the same. Why does the color change when adding/removing a #?
jsFiddle
As a basic premise, additional hashes are interpreted as a missing/erroneous value and so replaced with a zero, so ##89969E becomes #0089969E. Note that HEX codes can be as long as 8 digits following a hash (if aRGB), where the last two refer to transparency
Missing digits are treated as 0[...]. An incorrect digit is simply
interpreted as 0. For example the values #F0F0F0, F0F0F0, F0F0F, #FxFxFx and FxFxFx are all the same.
When color strings longer than 8 characters or shorter than 4
characters are used, things start to get strange.
However there are a lot of nuances - you can find out more about this here, and for some fairly entertaining results this creates, have a little read here
Related
I want to create a pattern for an HTML input field that needs to have at least 10 numbers in it and may also have spaces and a plus sign on top of that, but it's not required.
It's important that numbers and spaces can be mixed though. Also, the whole field can only have 17 characters all in all.
I'm not sure if it's even possible. I started doing something like that:
pattern="[0-9+\s]{10,17}*"
But like this, it's not guaranteed that there are at least 10 numbers.
Thanks in advance! Hope the question doesn't exist already, I looked but couldn't find it.
You can use
pattern="(?:[+\s]*\d){10,17}[+\s]*"
The regex matches
(?:[+\s]*\d){10,17} - ten to seveteen occurrences of zero or more + or whitespaces and then a digit
[+\s]* - zero or more + or whitespaces.
Note the pattern is anchored by default (it is wrapped with ^(?: and )$), so nothing else is allowed.
I´m searching for a list of exponents like ¹²³ and so on and the same with letters. Note these still remain superscripted even in plain text.
Does something like these exist? If not, how can I create those?
(I need them for a website-project)
Unicode versions of superscripted/subscripted characters exist for all ten digits but not for all letters. They remain superscripted/subscripted in a plain-text environment without the need of format tags such as <sup>/<sub>.
However (as of v14), not all letters have Unicode superscripts. Furthermore, they are scattered along different Unicode ranges, and are in fact used mainly for phonetic transcription. Additionally, they are used for compatibility purposes especially if the text does not support markup superscripts and subscripts.
Exponent characters:
These are mostly used for mathematical and referencing usage.
- ⁰ [U+2070]
- ¹ [U+00B9, Latin-1 Supplement]
- ² [U+00B2, Latin-1 Supplement]
- ³ [U+00B3, Latin-1 Supplement]
- ⁴ [U+2074]
- ⁵ [U+2075]
- ⁶ [U+2076]
- ⁷ [U+2077]
- ⁸ [U+2078]
- ⁹ [U+2079]
- ⁺ [U+207A]
- ⁻ [U+207B]
- ⁼ [U+207C]
- ⁽ [U+207D]
- ⁾ [U+207E]
- ⁿ [U+207F]
- ⁱ [U+2071]
The "linear", "squared", and "cubed" subscripts are the most familiar and are found in Latin-1 Supplement. All the others are found in Superscripts and Subscripts. Add 0x2070 to all the non-Latin-1 Supplement superscripts to obtain the code point value of these digits. See this Wikipedia article and the official Unicode codepage segment.
Interesting notes
There are also subtle differences between <sup> subscripts and Unicode subscripts; Unicode subscripts are entirely different codepoints altogether, and some fonts professionally design subscripted letters because <sup> subscripts may look thin.
Compare x² with x2, similarly x⁺ with x+ (the first involves Unicode, the second is markup)
The best solution is to use markup, such as <sup>.
You can't create the characters, but you can format then as super-scripts if you are generating HTML.
As to find which exist, you just have to use an unicode-character searching resource and look for "superscript" to have a listing -
This query, for example:
https://www.fileformat.info/info/unicode/char/search.htm?q=superscript&preview=entity
As you can see, all digits are available (more than once, even), but very few letters.
However, if you intend to generate HTML output, the <sup> tag will work for any text you want, and give the necessary semantic meaning to the text - you can read about it and try it online here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup
Apart from readability, what is the difference between the HTML codes
and 
?
ASCII Code
HTML Entity 

Hexadecimal value
These are all referring to the same thing but are represented in different ways. They all translate to Unicode U+0000A LINE FEED (LF)
Example:
The number 2 can be represented using 1+1. It can also be represented using |sqrt(4)|. The result is the same, but using different syntaxes we can achieve the same result in different ways.
References:
https://theasciicode.com.ar/ascii-control-characters/line-feed-ascii-code-10.html
https://www.quackit.com/character_sets/unicode/co_controls_and_basic_latin_unicode_character_codes.cfm
https://www.w3schools.com/html/html_symbols.asp
https://www.w3schools.com/charsets/ref_html_ascii.asp
This question already has answers here:
Regex to match only letters
(20 answers)
Closed 8 years ago.
I'm trying to create a regex for a HTML5 input so a user can only insert alpha characters that may be in a name. So characters from a-z, but also including ö,ü,â,æ ... and so on whilst also allowing whitespace and hyphens .
I have played around with some pattens but nothing seems to work correctly, this is what I have so far: <input type="text" name="firstname" pattern="[a-zA-Z\x7f-\xff] " title="">
Does anyone have a quick answer for this?
Since the HTML5 pattern attribute uses the same regex syntax as JavaScript, there is no simple way to refer to all alphabetic characters. You would need to write a rather huge expression (and to update it as new alphabetic characters are added to Unicode). You would need to start from the Unicode character database and the definition of General Category of characters there, or rely on someone having done that for you.
However, for your practical purposes, testing for “alpha characters that may be in a name” is even more complex. There are non-alphabetic characters used in names, such as left single quotation mark (‘) in addition to normal quotation mark (’), and who knows what characters there might be? If this is about people’s real names, it is very difficult to impose restrictions that do not discriminate. If this is about user names in a system, for example, you can define the repertoire as you like, but [a-zA-Z\x7f-\xff] does not look adequate (it includes some control characters and some non-alphabetic characters and excludes many Latin letters commonly used in Europe).
There is a very simple method to apply all you RegEx logic(that one can apply easily in English) for any Language using Unicode.
For matching a range of Unicode Characters like all Alphabets [A-Za-z] we can use
[\u0041-\u005A] where \u0041 is Hex-Code for A and \u005A is Hex Code for Z
'matchCAPS leTTer'.match(/[\u0041-\u005A]+/g)
//output ["CAPS", "TT"]
In the same way we can use other Unicode characters or their equivalent Hex-Code according to their Hexadecimal Order (eg: \u0100–\u017FF) provided by unicode.org
Try: [À-ž] as an example of Range. Modify your Range according to your requirement.
It will match all characters between À and ž.
Sample regEx would be
/[A-Za-zÀ-ž\-\s]+/
For more Ref: Latin Unicode Character
Today I discovered this by accident:
<hr width=100% color=red />
creates a red horizontal rule, but
<hr width=100% color=red/>
creates a green horizontal rule.
This isn't just with the color red, if there is a / directly behind the color name, another color will be drawn. This doesn't work for color codes like #000000 (to #000000/).
Just of curiosity, here is my question: How does the color get chosen? Is this a bug or intended?
Additional info:
Browser: Google Chrome 29.0.1547.66 m
Installed plugins / add ons: Ad Block Plus
I tested this with IE 10 and it has the same problem as Chrome.
This is, somewhat surprisingly, intentional error handling, described in clause 2.4.6 Colors of HTML5 CR. It is presumably meant to maintain compatibility with legacy content that has weirdly broken color designators that have been traditionally processed in a certain manner by browsers.
When the mixed-syntax (partly HTML, partly XHTML) markup <hr width=100% color=red/> is used, in a document served as text/html (when served with an XHTML content type, it would simply cause nothing but an error message to be shown), the color attribute will be parsed as red/ (with the slash as part of the value). Since this does not match any color name, rules for parsing a legacy color value will be applied.
This means that any character that is not a hexadecimal digit is replaced by the digit 0, and if the resulting value is not six characters long, trailing zeroes will be added. Finally, the value is prefixed with #, so it will be interpreted as a hexadecimal color designator. Thus, red/ yields #0ed000, which is the light green color that you see.
Similarly, <hr width=100% color=blue/> would cause the color #b00e00 to be used.
The problem can of course be avoided by using either HTML syntax (which has no / before >) or XHTML syntax (which has quotation marks around each attribute value).
The semantic analizer of your browser detect the <hr> tag and later try to determinate the atributes for that label.
Using white spaces as token separator, your first line have 3 attributes (noted that the correct slash for finish a tag in html is / ). In this case, the second token color=red as interpreted as a attribute (color) and value (red). In your second line there are only 2 attributes. The second attribute (color) has the value red\ that is not a valid identifier in the asociative array for colors.
Why your browser return blue?
Each browser manage the exceptions that diferents ways, its problably that your browser return the first value in the asociative array colors.
I should recommend to you that use quotes as delimiter for attributes values.
I just tried it,and it works.
First I copy your code and execute, it was unexpected. Still I try same code, and I just put " " (double quotes) around the color name, and tried color codes too.
and I found, it is working properly with Crome,IE and Mozilla.
using the color attribute might be the problem. Try border-color.
<hr width="100%" style="border-color:#f00">