3

I'm trying to split the following CSS rule into two lines:

background: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBR‌​AA7") 0 0 repeat;

I tried splitting the url base64 string into two sub strings to avoid going over the line length according to the style guide for an open source project called PDF.js.

I tried doing "xxxx" + "xxxx" and that didn't work.

So I was wondering if anyone has tried to do that before or if it is even possible to concat two strings in a css rule?

8
  • 2
    Do you think that style guide even applies in this case? Commented May 30, 2014 at 1:35
  • @WesleyMurch Good question. I have noticed other instances of CSS rules in the file that I'm trying to modify where the rules were longer than the suggested guideline. I wanted to check if it was possible at all. So I think in this case the style guide doesn't apply. Commented May 30, 2014 at 1:38
  • Well, add your own answer with your new-found knowledge - ref. w3.org/TR/CSS2 Commented May 30, 2014 at 1:50
  • Ok sweet. It works. Thanks for the help. I will add my own answer then. Commented May 30, 2014 at 1:52
  • 1
    @Mido: No, seriously, that is how you concatenate strings in CSS. jsfiddle.net/BoltClock/dF6h3 I'm just addressing your question. Commented May 30, 2014 at 4:30

1 Answer 1

1

According to the CSS2 specification http://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#strings, there is no concat operation. However, you can split strings on multiple lines for aesthetic reasons.

It is possible to break strings over several lines, for aesthetic or other reasons, but in such a case the newline itself has to be escaped with a backslash ().

So the solution to my problem would be:

  background: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAA\
                   LAAAAAABAAEAAAIBR‌​AA7") 0 0 repeat;

Which is kind of related to this question

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.