Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is word-wrap style safe to apply on body?

Tags:

html

css

Is this safe?

* { word-wrap: break-word }

I have too many places where I have to apply this style. Could any evil come from this line? What issues I may have?

like image 582
BrunoLM Avatar asked Dec 22 '10 21:12

BrunoLM


3 Answers

First, * is technically not just on the BODY but also HTML (yes, sometimes it matters).

Secondly, in isolated cases, using the wildcard can cause performance issues. I have only seen this when using something (admittedly horrible) like DHTML behaviors, but in my opinion it would be better to declare an explicit set of elements to which it applies.

Lastly, it will clutter up all your CSS viewing tools with a potentially unneeded statement.

So, no big problem, but I would suggest just listing the elements that it is actually relevant to, such as P, possibly TD, DIV, etc.

like image 130
Tim M. Avatar answered Oct 03 '22 07:10

Tim M.


I believe there's no evil in that. Usually I measure the CSS parameters I need and decide wich ones will belong to the document and wich ones are to be treated locally. In your case, if you find that usefull, you just need to ensure that any element that you don't want to behave like that is properly told so.

like image 28
yoda Avatar answered Oct 03 '22 06:10

yoda


I apply it just to the body element, like the question suggests:

body { word-wrap: break-word; }
like image 20
martinedwards Avatar answered Oct 03 '22 06:10

martinedwards