How to apply a bootstrap class to every same HTML element in css file? for example, if I want to apply a bootstrap class "pull-right" to every tag I require to put class name inside a class attribute in every tag presently. is there any way to right once and effect anywhere in html file?
Asked
Active
Viewed 2,229 times
0
-
You can use jQuery or pure JavaScript `document.getElementsByTagName("*")` to select all elements in your HTML page and apply the class to it, but the question is if you want to select all elements why not use a CSS selector for that? in pure CSS it's kinda tricky to apply a class to a selector though, easier to copy the content of your bootstrap css class. – xander Dec 12 '17 at 13:51
-
This is why it is better to *write CSS* rather than sticking presentational class names into HTML. – Quentin Dec 12 '17 at 13:52
1 Answers
-1
You can use asterix *
to apply styles to all tags. But you can't apply styles of class
to elements in clear css. You can do this using scss
http://sass-lang.com/ or less css
http://lesscss.org/
here is an example in less css
* {
.pull-right;
}

Sylwek
- 856
- 1
- 9
- 24
-
-
Here you have examples how to do this with SASS https://stackoverflow.com/questions/9560170/including-another-class-in-scss – Sylwek Oct 18 '18 at 06:37