When generating page markup, Tumblr’s template engine outputs any single line (or paragraph) entered into its source, caption or description fields without any containing elements (ie, no
<p>tags). Containing elements are only added when there is at least two lines of copy, separated by a blank line.Although this behaviour is commonplace in text-to-HTML converters, it can prove troublesome when your CSS expects consistent markup in all cases. Here’s a little piece of jQuery magic I wrote to solve this issue for a new theme I’m working on:
$(".content:not(:has(p,ol,ul,dl,blockquote))")
.wrapInner("<p></p>");It looks for every element with a class of (in my case)
content, checks to see if the element contains any of five common block-level children, and if not, wraps the content in a paragraph tag. You’ll need at least jQuery 1.3 for this selector combination to work.
-
haydenhunter liked this
-
jbrewer liked this
-
dannygarcia liked this
-
jerrybrito liked this
-
ferrydust liked this
-
trey liked this
-
pilnick liked this
-
johnburke liked this
-
paulgiacherio liked this
-
jarredbishop liked this
-
toyra liked this
-
nttm liked this
-
rinsespin liked this
-
esquareda liked this
-
dannygarcia reblogged this from matthewb
-
evanwalsh liked this
-
jonic liked this
-
bsag reblogged this from matthewb and added:
Useful. The missing...tags on the automatically imported Twitter fed has irritated me
-
brier liked this
-
dydric liked this
-
michaellynton liked this
-
petervidani liked this
-
pierreism liked this
-
mattschwarz reblogged this from matthewb
-
mattschwarz liked this
-
jennul liked this
-
shabdar reblogged this from matthewb
-
acc liked this
-
thebronzemedal liked this
-
sneak liked this
-
topherchris liked this
-
svnlto liked this
-
copacetic reblogged this from matthewb
-
copacetic liked this
-
minorjive reblogged this from matthewb
-
matthewb posted this