1

I've tried creating the following HTML file in Chrome:

<style>
br {
}​

[required] {
  border-width: 3px;
  border-color: red;
}

</style>
<input required />

that is the complete content of the file. The [required] rule does not match and the <input> remains unstyled.

If the empty br rule is left out so that the file reads:

<style>

[required] {
  border-width: 3px;
  border-color: red;
}

</style>
<input required />

It works fine!

Why would the existence of the <br> rule before the [required] one cause [required] to not match?

Thanks. (It works fine is jsfiddle, you need to actually create the files.)

Adam
  • 43,763
  • 16
  • 104
  • 144

2 Answers2

2

Your new line is invalid somehow. The code performs as expected when they are removed.

I've traced the problem to right after the closing bracket for br. here's what I get in vim:

<style>
br {
}<200b>

[required] {
  border-width: 3px;
  border-color: red;
}

</style>
<input required />

Apparently <200b> is the Unicode zero width space. I am not familiar with this character and don't know why it would be present in this file. Deleting it resolves the issue.

matt3141
  • 4,303
  • 1
  • 19
  • 24
  • I've typed code from question into my editor, and created file. And I've got same problem as Adam. – Miljan Puzović Aug 20 '12 at 23:27
  • @MiljanPuzović I am aware that there is an issue and I have traced it down. The question is how this odd character got there to begin with. – matt3141 Aug 20 '12 at 23:43
  • That's so strange. I have no idea how that got there. Great catch! – Adam Aug 20 '12 at 23:46
  • @matt3141 You're right, i didn't get it before last edit of your answer. – Miljan Puzović Aug 21 '12 at 00:04
  • According to an answer to a question on [zero width space](http://stackoverflow.com/questions/7055600/u200b-zero-width-space-characters-in-my-js-code-where-did-they-came-from), it may have been generated by Chrome Inspector. – Jukka K. Korpela Aug 21 '12 at 04:09
-1

i think that the br is helping trick the browser - because their are more brackets...

i think you are missing something...

.required{} and
<input class="required">  


or 
#required{} and
<input id="required">

lets have the fiddle !

sheriffderek
  • 8,848
  • 6
  • 43
  • 70