Div tag inside a tag

Using a rich text field. Every time I attempt to save a

tag inside of an tag. The
tag automatically gets saved after the tag, instead of inside the tag. Also, for some reason anchor tags wouldn’t let me save text inside of it. I was attempting to use a tag or a tag on all occasions, so maybe its a similar issue.

Heather,

Can you look over the appearance of your post here? The CM1 community allows some HTML in its posts, and I believe you might’ve used some actual div tags in your post here which has compromised the content of your post. Sorry about that. Once that’s been cleared up, I will be happy to look into your issue.

Nathaniel

haha, I am sorry. Using a rich text field. Every time I attempt to save a
“div” tag inside of an “a” tag. The “div” tag automatically gets saved after the “a” tag, instead of inside the “a” tag. Also, for some reason anchor tags wouldn’t let me save text inside of the tag. I was attempting to use a “b” tag or a “strong” tag on all occasions, so maybe its a similar issue.

Heather,

No problem!

So, the Rich Text editor follows a set of rules regulating what HTML it allows when you edit the source code. One of those rules is you cannot place block elements within anchor tags, only inline elements – this is not regarded as valid HTML except when using HTML5, and many CM1 users still use the XHTML DocType. You can still style inline elements such as “span” elements and place them within your anchors, and with some CSS tweaking achieve the results you’re looking for.

Another option would be to use an HTML widget in cases where you need to break from the Rich Text editor’s HTML rules. However, if you do plan on using code which only HTML5 will validate, remember to switch your template’s DocType to HTML5 through your template’s meta-data.

Hope this helps,
Nathaniel

I used span instead of div and adjusted my css accordingly. Our client uses the div inside of the a tag. I didn’t realize I could switch my doctype, thanks, will that cause the rich text fields to act differently? Or that is the case when I should use the HTML widget?

HTML generated by the Rich Text widget should not be affected when you switch doctypes, and the Rich Text widget will still follow the same rules in terms of the HTML it generates regardless of your doctype. I was recommending the doctype switch if you planned on using code such as a div inside of an anchor tag in an HTML widget. Be aware, if you have any XHTML or HTML5 specific code in an HTML widget, it’s possible their behavior will change when you switch doctypes.