[wp-trac] [WordPress Trac] #48052: <center> tag around [video] inserts &nbsp and new lines every post update (or even switch between source and post)

WordPress Trac noreply at wordpress.org
Fri Nov 27 10:37:41 UTC 2020


#48052: <center> tag around [video] inserts &nbsp and new lines every post update
(or even switch between source and post)
-------------------------------------+-----------------------------
 Reporter:  archon810                |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Future Release
Component:  Editor                   |     Version:  5.3
 Severity:  normal                   |  Resolution:
 Keywords:  needs-patch 2nd-opinion  |     Focuses:
-------------------------------------+-----------------------------
Changes (by sabernhardt):

 * keywords:  needs-patch => needs-patch 2nd-opinion


Comment:

 There are better ways to center a video than wrapping it the obsolete
 `center` tag.
 ([https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center MDN
 docs discourage using the tag].)

 ==== Option 1: Center all videos added with [video] shortcodes.

 1. Navigate to Appearance > Customize.
 2. Find the "Additional CSS" section.
 3. Paste the following CSS:
 {{{
 .wp-video {
         margin-left: auto;
         margin-right: auto;
         text-align: center;
 }
 }}}
 4. Publish.

 ==== Option 2: Center each video individually with a `div` tag.

 Wrap the shortcode with a `div` tag that includes centering styles and a
 `max-width` equal to the number of pixels defined in the video shortcode's
 width value.

 {{{
 <div style="margin-left: auto; margin-right: auto; text-align: center;
 max-width: 524px;">

 [video width="524" height="1080" mp4="https://example.com/wp-
 content/uploads/2019/09/test.mp4"][/video]

 </div>
 }}}

 If the width is always the same, you could use a `class` instead of a
 `style` attribute and set those styles in Additional CSS.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48052#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list