I would like to open a div container in one question and close it within another, after I place several questions within this container so I can hide it later on using the CSS-Layout. But everytime I save the question with an open div it automatically closes it up (probably to prevent errors). Normally I would be thankful for this function but I would like to turn it off in this case. Can anybody tell me how this might be possible, that would be truly great
As holch suggests, you can do this with the WYSIWYG editor disabled but you will need to ensure that the question is never edited with the WYSIWYG in the future.
I'm not sure you will get valid HTML anyway. For example, it seems to me that a <div> opened in one question and closed in another will cause the closing </div> tag for Q1 to be inside another <div> which is invalid.
@Tpartner: I haven't followed the latest HTML coding standards too closely, but why would be a DIV in a DIV not valid? We could argue if it is good style or not and that we should try to use the semantically correct tags, but I don't see why a block element could not contain another block element...
I was searching a bit and I couldn't find any reference of a div in a div not being valid HTML. Do you have a link for that?
Help us to help you!
Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
Of course, a div in a div is acceptable, what I'm referring to is a div starting in one div and ending in another.
Code:
<div class="question-1">
<!-- Start of inserted div -->
<div class="inserted-div">
</div>
<div class="question-2">
</div>
<!-- End of inserted div -->
</div>
Cheers,
Tony Partner Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Now looking at your example, the problem is not that it is not valid. The code is perfectly valid. Because the inserted div will be basically closed the the closing div-tag that is supposed to close the question 1 div. Then the question 2 div opens and includes basically question 2 within the question 1 div. The question 2 div is closed by the inserted closing div tag and then the last div closes question 1.
Perfectly valid, but it goes totally against what the divs are supposed to do...
Help us to help you!
Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
<div class="question-1">
<!-- Start of inserted div -->
<div class="inserted-div">
</div>
<div class="question-2">
</div>
<!-- End of inserted div -->
</div>
The code should be interpreted by the browser like this:
Code:
<div class="question-1">
<div class="inserted-div">
</div> // Originally this should close the "question-1" div, but it actually closes the "inserted-div" already
<div class="question-2">
</div> // This one was supposed to close the "inserted-div", but what it actually does now is closing the "question-2" div already.
<!-- End of inserted div -->
</div> // This one originally should close "question-2", but now it closes "question-1"
Totally valid code, just doesn't work as it is intended.
Help us to help you!
Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
Thank you so much for your answers, you helped me a lot. However, now I might one follow-up question:
- How can I assign a class to a certain question?
The thing is, I am copying the code of one question into another, so I can have a five-star rating within a text shown. The problem is, the question pops up twice on the same page. Once in the spot where it is supposed to pop up when considering LimeSurvey and the other time where I copied the code. Clearly I only want the copied question to show up and the other question to disappear. But if I address the question directly via id-Tag it of course affects both questions. So if I could assign a class to a question that would be the easiest thing, but I don't see how I can get around to that. Maybe this clarifies the aim I am trying to achieve. Thanks again for the great support!!