Embedded Twitter XHTML Strict

greg's picture

He has: 1,581 posts

Joined: Nov 2005

I'm trying to get the embedded Twitter code to validate in XHTML Strict.

The Code:

<embed height="176" align="middle" width="176"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always"
name="twitter_badge" quality="high" flashvars="color1=16594585&type=user&id="
src="http://twitter.com/flash/twitter_badge.swf"/>

At first W3C moaned about height="176" align="middle" width="176" and suggested I use a CSS. I tried its suggestion and now it moans about the CSS Doh!

Attribute "class" exists, but can not be used for this element.
<embed class='right_menu_twitter'

(same result for a CSS ID)

It's also saying

Attribute "pluginspage" is not a valid attribute
Attribute "type" exists, but can not be used for this element.
Attribute "wmode" is not a valid attribute. Did you mean "code" or "frameborder"?

And a bunch of other stuff. Is there a way to wrap this in something to allow all the stuff in the code to be validated?
I'd hate to have to switch to transitional for this, the site is 99% done and everything else is strict.

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

Is there a way to wrap this in something to allow all the stuff in the code to be validated?

Use javascript to embed the embed content. You could do something like:

HTML:

<div id="embed-here"></div>

JS:

// you might need to use window.onload, I can never remember which it is
document.onload = function(){
  document.getElementById("embed-here").innerHTML = "Your HTML stuff here";
};

He has: 629 posts

Joined: May 2007

@teammatt3 is on to something. Check out Adobe's article on embedding SWF files with SWFObject 2 for their recommendations.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.