css selectors - What does .container.\31 25\25 mean in CSS? -


in code below, wondering \ backslash might mean? have not encounter backslash character in lessons i've been taking. piece of code used identify browser sizes, believe.

.container.\31 25\25 {   width: 100%;   max-width: 1500px;  /* max-width: (containers * 1.25) */   min-width: 1200px;  /* min-width: (containers) */ } .container.\37 5\25 { /* 75% */   width: 900px;       /* width: (containers * 0.75) */ } .container.\35 0\25 { /* 50% */   width: 600px;       /* width: (containers * 0.50) */ } .container.\32 5\25 { /* 25% */   width: 300px;       /* width: (containers * 0.25) */ } 

according spec,

identifiers can contain escaped characters , iso 10646 character numeric code (see next item). instance, identifier "b&w?" may written "b\&w\?" or "b\26 w\3f". [...]

in css 2.1, backslash (\) character can indicate 1 of 3 types of character escape. inside css comment, backslash stands itself, , if backslash followed end of style sheet, stands (i.e., delim token).

first, inside string, backslash followed newline ignored (i.e., string deemed not contain either backslash or newline). outside string, backslash followed newline stands (i.e., delim followed newline).

second, cancels meaning of special css characters. character (except hexadecimal digit, linefeed, carriage return, or form feed) can escaped backslash remove special meaning. example, "\"" string consisting of 1 double quote. style sheet preprocessors must not remove these backslashes style sheet since change style sheet's meaning.

third, backslash escapes allow authors refer characters cannot put in document. in case, backslash followed @ 6 hexadecimal digits (0..9a..f), stand iso 10646 ([iso10646]) character number, must not zero. (it undefined in css 2.1 happens if style sheet contain character unicode codepoint zero.) if character in range [0-9a-fa-f] follows hexadecimal number, end of number needs made clear. there 2 ways that:

  1. with space (or other white space character): "\26 b" ("&b"). in case, user agents should treat "cr/lf" pair (u+000d/u+000a) single white space character.
  2. by providing 6 hexadecimal digits: "\000026b" ("&b")

in fact, these 2 methods may combined. 1 white space character ignored after hexadecimal escape. note means "real" space after escape sequence must doubled.

if number outside range allowed unicode (e.g., "\110000" above maximum 10ffff allowed in current unicode), ua may replace escape "replacement character" (u+fffd). if character displayed, ua should show visible symbol, such "missing character" glyph (cf. 15.2, point 5).

therefore, following equivalent:

.container.\31 25\25   <-->   .container[class ~= "125%"] .container.\37 5\25    <-->   .container[class ~= "75%"] .container.\35 0\25    <-->   .container[class ~= "50%"] .container.\32 5\25    <-->   .container[class ~= "25%"] 

note escaping important, otherwise wouldn't valid identifiers (emphasis mine):

in css, identifiers (including element names, classes, , ids in selectors) can contain characters [a-za-z0-9] , iso 10646 characters u+00a0 , higher, plus hyphen (-) , underscore (_); cannot start digit, 2 hyphens, or hyphen followed digit.

therefore, following invalid:

.container.125% .container.75% .container.50% .container.25% 

maybe may clearer fiddle:

.container {    background: red;    margin: 10px;  }  .container.\31 25\25 { /* 125% */    width: 100%;    max-width: 1500px;  /* (containers * 1.25) */    min-width: 1200px;  /* (containers * 1.00) */  }  .container.\37 5\25 { /* 75% */    width: 900px;       /* (containers * 0.75) */  }  .container.\35 0\25 { /* 50% */    width: 600px;       /* (containers * 0.50) */  }  .container.\32 5\25 { /* 25% */    width: 300px;       /* (containers * 0.25) */  }
<div class="container 125%">125%</div>  <div class="container 75%">75%</div>  <div class="container 50%">50%</div>  <div class="container 25%">25%</div>


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -