Can I use attr() inside background url() in CSS? [duplicate] - css

This question already has an answer here:
Using HTML attributes as CSS property values [duplicate]
(1 answer)
Closed 9 years ago.
I would like to do this in HTML:
text
and in CSS:
a {
background-image: url(attr(href));
}
It doesn't seem to work for me. Is it even possible?

Not possible in static CSS file. However you can have dynamically generated CSS by any server side language such as PHP.
Or use Sass or LESS if you need variables in CSS.

Related

CSS - Using attr() function without ::before and ::after [duplicate]

This question already has answers here:
CSS3's attr() doesn't work in major browsers
(5 answers)
Closed 5 years ago.
I want to useattr()function in some span, but I won't use ::after and ::before pseudo-elements. For example:
<span size="36">Text</span>
<style>
span[size]{
font-size: attr(size pt);
}
</style>
Is it possible to do so using CSS or SASS or LESS?
The attr() returns a string and as such the only property it will practically work on as of today is the content property.
In your case it will return the string 36 and will therefore not be properly applied.
Its syntax has an experimental second parameter, <type-or-unit>, where one amongst other should be able to choose the returned value's data type, though no browser support it yet.
A side note, both SASS and LESS compiles into CSS and aren't able extend the CSS into something CSS can't already do.

Is it possible to use a css class in another css class? [duplicate]

This question already has answers here:
Is it possible to reference one CSS rule within another?
(6 answers)
Closed 8 years ago.
What I'm trying to do is refer a css class in another css class:
.customClass1{
//some styles
}
.customClass2{
//some styles
}
.customClass3{
use customClass1;
use customClass2;
}
Is this even possible?
You should use a CSS pre-processor like LESS, then you can use Mixins LESS Mixins

Meaning of '*' before any CSS attribute [duplicate]

This question already has answers here:
What does a star-preceded property mean in CSS?
(4 answers)
Closed 9 years ago.
what is meaning of '*' before any CSS attribute like.
.hello
{
margin-top:5px;
*margin-top:10px;
}
Thanks
Vishal
I'll answer this because it has a quick answer. Basically it's a hack to define IE only styles. IE will ignore the syntax error and apply the CSS rule anyway. However I don't recommend it. Instead use conditional comments because its safer

How to use variable in CSS? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Create a variable in .CSS file for use within that .CSS file
I heard about that we can declare/define variable in CSS and use them like global variables like this:
#nice-blue: #5B83AD;
#header { color: #nice-blue; }
So anyone knows how to use them?
For that you need to use Less or Sass which are CSS Dynamic languages.
here's some comparison between both technologies.
You need to use something like SASS
http://sass-lang.com/#variables
or Less
http://lesscss.org/
There is a language written on top of CSS which make use of variables like you asked, it's called LessCSS

What should I do to prevent GWT from using its theme and totally use the CSS that I specify [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
GWT theme style overrides my css style
What should I do to prevent GWT from using its theme and totally use the CSS that I specify?
Well, you can be radical and just remove the CSS files that are in the com.google.gwt,user.theme.chrome/dark/standard packages (don't forget to remove then from the gwt.xml file). Then specify your own CSS....disadvantage is that you have to style absolutely everything yourself. Hope this helps.

Resources