Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,660 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.