Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Stefan Ristic
Stefan Ristic
7,595 Points

Asterisk right before the CSS property?

Hello and thank you for taking a look at this thread :)

I have a task to make the website HTML/CSS valid, and I found something that I haven't seen before, so I would really appreciate a quick explanation if possible.

Long story short, there are hundreds of same errors on the page, and this is one of those errors:

.mobile-push-5:

Parse Error *left: expression(Math.floor(0.05 * (this.parentNode.offsetWidth - parseFloat(this.parentNode.currentStyle.paddingLeft) - parseFloat(this.parentNode.currentStyle.paddingRight))) + "px");

Here is how it looks in CSS:

.mobile-push-5 { left: 5%; *left: expression(Math.floor(0.05 * (this.parentNode.offsetWidth - parseFloat(this.parentNode.currentStyle.paddingLeft) - parseFloat(this.parentNode.currentStyle.paddingRight))) + "px"); }

What is the purpose of this Asterisk, and can I somehow make this valid without breaking the layout?

1 Answer

Sean T. Unwin
Sean T. Unwin
28,690 Points

In CSS the * is the universal selector for an instance of any element type.

However, in your example it appears to be used in a different manner as it is used with a property. Which library or framework is this from?

The use of expression() is deprecated and should not be used as there are performance and security issues associated. This was initially implemented in IE, but has since been discontinued since IE8 (even if some browsers are still able to implement it).

JavaScript should be used, but not inside the CSS file.