Allow include tag names like H1, H2, ... as mixins #1011

Closed
alexeypetrushin opened this Issue Oct 30, 2012 · 7 comments

4 participants

@alexeypetrushin

What do You think about allowing to use tag elements like H1, H2, .... as mixins?

Use Case

I'm using Twitter Bootstrap and create header for page. Currently, because I can't reuse styles from H1 element I has to put extra stuff into HTML and code looks like that:

<div class='header'>
  <h1>
    <a href='#'>Some text</a>
  </h1>
</div>
.header {
  h1 {
    float: left;
  }
}

But if it would be possible to reuse styles on H1 the HTML code could be more clean:

<div class='header'>
  <a href='#' class='header-title'>Some text</a>
</div>
.header {
}
.header-title {   
  float: left;
  // Including
  .h1()
}

At fist I though to post an issue to Twitter Bootstrap project and ask them to create alias for every tag name (like .h1 for H1), but then realized that it would be better if LESS allow to use tags as mixins.

What do You think?

@lukeapage
Less member
@lukeapage
Less member
@alexeypetrushin

... the more complex less can look ...

Actually it's more complex with special syntax for mixins. You has to remember special syntax and supply it vs. beeng just able to use anything as mixin instantly.

So, it's actually a simplification and making the syntax more consistent.

P.s. in your use case couldn't you just swap things round and put the rules on the class?

No, big part of rules defined in vendor css file (in Twitter Bootstrap CSS Framework) - so I has to change vendor css file or copy-paste it - it's not good. I just want to alter it a little - with mixins it's easy.

@adrianheine

@alexeypetrushin Take a look at this SO answer, it might show you a way to solve your problem.

@gaurav21r

Lets move the discussion to #1048

@lukeapage
Less member

moved to #1048

@lukeapage lukeapage closed this Nov 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment