Are the WordPress Core CSS styles really all nessesary?

On WordPress Codex there are these CSS styles listed. It’s a quite big list of styles, but it seems they are doubled unnecessary.

It says:

Each Theme should have these or similar styles in its style.css file
to be able to display images and captions properly. The exact HTML
elements and class and ID values will depend on the structure of the
Theme you are using

Does this mean all these styles should be in a theme?

What’s the reason for this specificity for the align styles that are already declared? By looking at this, it seems it could be reduced drastically.

What are the disadvantages in reducing this to a minimum?

/* =WordPress Core from http://codex.wordpress.org/CSS#WordPress_Generated_Classes
-------------------------------------------------------------- */

.alignnone {
    margin: 5px 20px 20px 0;
}

.aligncenter,
div.aligncenter {
    display: block;
    margin: 5px auto 5px auto;
}

.alignright {
    float:right;
    margin: 5px 0 20px 20px;
}

.alignleft {
    float: left;
    margin: 5px 20px 20px 0;
}

.aligncenter {
    display: block;
    margin: 5px auto 5px auto;
}

a img.alignright {
    float: right;
    margin: 5px 0 20px 20px;
}

a img.alignnone {
    margin: 5px 20px 20px 0;
}

a img.alignleft {
    float: left;
    margin: 5px 20px 20px 0;
}

a img.aligncenter {
    display: block;
    margin-left: auto;
    margin-right: auto
}

.wp-caption {
    background: #fff;
    border: 1px solid #f0f0f0;
    max-width: 96%; /* Image does not overflow the content area */
    padding: 5px 3px 10px;
    text-align: center;
}

.wp-caption.alignnone {
    margin: 5px 20px 20px 0;
}

.wp-caption.alignleft {
    margin: 5px 20px 20px 0;
}

.wp-caption.alignright {
    margin: 5px 0 20px 20px;
}

.wp-caption img {
    border: 0 none;
    height: auto;
    margin: 0;
    max-width: 98.5%;
    padding: 0;
    width: auto;
}

.wp-caption p.wp-caption-text {
    font-size: 11px;
    line-height: 17px;
    margin: 0;
    padding: 0 4px 5px;
}

3 s
3

The most definitive and up to date answer about best practice can come probably only from the wordpress.org theme review team, and right now they are different from the codex. just quoting it here, but I’m sure it might change with time

Themes are required to support the following WordPress-defined CSS classes, or similar elements:

 Alignment Classes:
    .aligncenter
    .alignleft
    .alignright 

Caption Related Classes:
    .wp-caption
    .wp-caption-text
    .gallery-caption 

Post Classes:
    .sticky 

Comment Classes:
    .bypostauthor

While needing to be present in the stylesheet, .sticky and
.bypostauthor can remain empty (unstyled) if desired. The intent is
simply to ensure that theme developers have considered all classes
generated by WordPress

By this it doesn’t look like you have to have all the CSS rules that are listed in the codex page you pointed to.

Leave a Comment