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;
}
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
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.
The
align*
andcaption
classes are generated by WordPress in shortcodes and image functions. You should use those in your stylesheet.Of course, the Codex text is just an example.
⦠is a very poor selector. Slower and more redundant than necessary.
Also, the class names are not semantic meaningful: in a right-to-left output (Arabic) you may use â¦
But that is not easy to change and probably not worth the effort. So ⦠live with it. 🙂
Yes, Nessesary.
When you develop wordpress theme, it requires all default wordpress core styles.
https://github.com/bangarayya/wordpress-core-styles
To Upload wordpress theme to Envato or wordpress.org the theme should follow wordpress codex rules https://codex.wordpress.org/.