The following code yields the embedded YouTube video below.
<p class="alignleft"> [youtube=http://www.youtube.com/watch?v=kTMwwMaipSw&w=320&h=205] </p> <hr />
Here’s the same video using the default YouTube embedding settings.
[youtube=http://www.youtube.com/watch?v=kTMwwMaipSw]
What’s wrong with the default settings for embedded YouTube videos on wordpress.com?
- The default alignment is automatically centered horizontally. I want mine aligned to the left.
- The default size is 425×350 pixels which adds black borders to the top and bottom of the videos. Also, I like my embedded videos to be 320 pixels wide for people browsing on smartphones.
To modify these settings, we’ll use the HTML editor on a wordpress.com post.
Adding class="alignleft" to the <p> tag takes care of the alignment issue. Use class="alignright" if you want it to align right.
Without the <hr />, the text would flow around the video like this.
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
Appending &w=320&h=205 to the YouTube shortcode lets us control the width and height of the embedded YouTube video.
If I wanted a 16:9 video to be 320 pixels wide, then the height would need to be 180 pixels. YouTube’s player bar is 25 pixels tall, so the final YouTube embedded video height should be 205 pixels. You’ll need to do your own math if you want to use a different width or have a 4:3 video.
I hope this helps my fellow wordpress.com users. Also, if you know a better way, please leave a comment. Thanks!
License

To the extent possible under law, Phloating Man has waived all copyright and related or neighboring rights to “Align and Resize YouTube Videos on wordpress.com“.
Very useful man – will use this on my main blog!
@Mo Glad you found it helpful!
Thank you so so so so much this has saved me so much time and energy, plus really cleaned up my website, especially my portfolio page. Again thank you so much.
@kenkoller
I’m glad I helped save you some time!
This is a great post on how to get your videos to line up the way that you want them to. I recently wrote a post about how to get and customize the embed code. Hope this helps someone: http://fatwalr.us/2010/12/how-to-embed-resize-youtube-video/
@Luke Thanks for the comment. Your instructions work well for wordpress self-hosted sites, but not for wordpress.com hosted sites since wordpress.com doesn’t allow the embed code.
Superb – I’ve been looking for this for a while now. Simple and to the point as well.
Glad you found it helpful. Happy blogging!
So this was working for me for the longest time, and now all of my videos are centered despite the align codes I had http://kenkoller.com/music-videos/
This was the code I was using and it was working fine. Suggestions?
[vimeo http://vimeo.com/16400190 w=318&h=178]
[vimeo http://vimeo.com/9995063 w=318&h=178]
[vimeo http://vimeo.com/16257047 w=318&h=178]
[vimeo http://vimeo.com/16091057 w=478&h=269]
[vimeo http://vimeo.com/15329336 w=478&h=269]
[vimeo http://vimeo.com/10219416 w=478&h=269]
[vimeo http://vimeo.com/10007827 w=478&h=269]
[vimeo http://vimeo.com/13898665 w=950&h=422]
@KenKoller I tested out the code again and it still works for youtube videos, but alignment doesn’t work for vimeo vidoes. I’ll let you know if I figure it out.
For what ever reason the code never worked but I ending up creating tables to organize the videos and align them. Check it out http://kenkoller.com/music-videos/
@KenKoller It still looks nice and clean with the tables.
Great help. Thanks, it worked like a charm. Have a nice time.
@ajay bantawa rai you’re welcome!
thanks for the clear concise information. Very helpful.
@The Judge You’re welcome!
Thank you very much! I have read a lot of different blogs without a right solution, but yours works perfectly!! ;D
@Roberto You’re welcome!
I get a “potential clickjacking” warning from NoScript for resized YouTube videos (like the one above). Do you know if there is anyway to not get this warning?
Unfortunately, I do not.. I get that too when using noscript.
I found out how to align Vimeo video’s, using this code:
[embed w=000&h=000]URL[embed]
Where 000 is your video size and URL is the vimeo url.
I’m still looking for a solution for a problem for the youtube videos: when using the tag, it just gives me a black line in my content. Putting two youtube videos using the p class tag together in one page, without the then they are placed next to each other, in stead of on top of each other (horizontally in stead of vertically) I’ve tried using the tag, but doesnt work..anyone have any idea?
oh, i see that every tag i’ve udes is converted into html, in stead of the actual symbols and letters…sorry, dont know how to fix that..
This is the most helpfull post I read about aligning. It’s been a great help so far! Thanks!
However, I get this weird line at the right top of my aligned video. Do you know how to fix this?
Example: http://garciagoodbye.wordpress.com/2011/11/28/obrigada-para-nos-fas-brasileiros/
Found a solution myself: I removed and then the line disapeared. Thanks though!
Very helpful–many thanks!
Thank You for your clear cut information.
OHHH THANK YOU SOOOO MUCH!!! very helpful and you are the ONLY person who easily answered all of questions about this!