Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 586 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CSS: Will a nonsense value for the 'display' property cause problems?

#1
I am using a CMS that allows data place holders with braces, like so:

Name: {First_Name} <br>
Email: {Email} <br>
Phone: {Phone} <br>

However it doesn't give me any way to do conditional output, like I can't hide the Phone line if the phone field is blank.

The CMS doesn't allow javascript or server side code. I came up with this trick:

Name: {First_Name} <br>
Email: {Email} <br>
<div style="display:none{Phone}">Phone: {Phone} <br></div>

If the person has no phone number, the div ends up display:none, but if they do, the div ends up with a nonsense value for display, and the whole div shows up.

It works in IE8, IE9, FF14, Chrome

Any reason I shouldn't do this?


Reply

#2
No, that's absolutely fine; a value that's not understood by the browser, in CSS, doesn't result in an error, it simply ignores that value and displays the element with its default setting for that property.

> [For] illegal values. User agents must ignore a declaration with an illegal value. For example:

> img { float: left } /* correct CSS 2.1 */
img { float: left here } /* "here" is not a value of 'float' */
img { background: "red" } /* keywords cannot be quoted */
img { border-width: 3 } /* a unit must be specified for length values */

> A CSS 2.1 parser would honor the first rule and ignore the rest, as if the style sheet had been:

> img { float: left }
img { }
img { }
img { }

Citation:

[To see links please register here]


Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through