Cancel vertical-align property - css

Is there a way to cancel or overcome a vertical-align property?
I have a website with a stylesheet containing the following CSS:
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p,
blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font,
img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i,
center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption,
tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption,
figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio,
video {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
background: transparent;
}
I have inserted a table on a page with its content showing up in a weird way because of this style property (meaning that if I uncheck "vertical-align: baseline" within Chrome developer tool, it shows up exactly how I want).
How can I reproduce that on my page?
Thanks!

This is an interesting question because it touches very much on the default style sheet of the browser.
If you look at the default style sheet given in the spec (http://www.w3.org/TR/CSS21/sample.html), you see the following:
thead, tbody,
tfoot { vertical-align: middle }
td, th, tr { vertical-align: inherit }
As a result, the default behavior is for the content of a table-cell to be vertically centered in the table cell.
In your style sheet, you are setting the vertical-align property to baseline for the tbody, tfoot, thead, tr, th and td elements, which is affecting your table layout.
You need to either adjust the CSS rule that resets the vertical-align property or add additional rules for the table styling as needed.
In your example, you can simply add the two rules given above after your
original rule.
Alternatively, leave out the vertical-align property from the original rule set.
To be more specific, alter your CSS style sheet as follows:
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p,
blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font,
img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i,
center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption,
tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption,
figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio,
video {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
background: transparent;
}
thead, tbody, tfoot { vertical-align: middle } /* add this rule*/
td, th, tr { vertical-align: inherit } /* add this rule */
by adding the two additional rules.

i am also using a wordpress template with the same "reset" in the stylesheet.
i didn't want to simply reset the reset in my child stylesheet -- untold number of errors that could cause, based on the convoluted css.
instead, in my "child" stylesheet, i added a class and defined that any table element within a item sporting that class would be vertically aligned to the middle:
.masthead-table table, caption, tbody, tfoot, thead, tr, th, td {
vertical-align: middle;
}
then in the page where it actually appears, i gave the div containing the table its proper class:
<div class="masthead-table">
<table>
<tr>
<td>
voila, my middle-v-aligned content
</td>
</tr>
</table>
</div>

You cannot cancel a property. By CSS principles, every element has all properties defined in CSS (though not all properties affect the rendering of an element).
Neither can you tell, in a style sheet, a browser to ignore a CSS rule appearing in another style sheet. You can only throw in your own settings, and they will then participate the cascade and may thereby override other settings.
There is no way to know what CSS settings may be present in browser default style sheets, user style sheets, and other page style sheets. The only way to ensure that things work as if a CSS rule were not present is to actually remove the rule. This is one reason why “CSS reset” rule sets are so risky.
If you have been forced to work in an environment where some “CSS reset” is present and cannot be removed or changed, you may need to study in detail which default settings they may override. There is no guarantee that this is successful, since browsers are free to have whatever they like in the default style sheets. But the settings that probably matter are those that are described and more or less recommended in HTML5, section Rendering. It describes the following:
sub { vertical-align: sub; }
sup { vertical-align: super; }
thead, tbody, tfoot, table > tr { vertical-align: middle; }
tr, td, th { vertical-align: inherit; }
... and some settings that define the valign attribute in terms of CSS, as well as some special rules for the new meter and progress elements.
Thus, vertical-align: baseline may cause several default rendering features to be overridden. You would need to analyze which of them apply and to make sure that you set vertical-align to suitable values for the elements where it matters.

Since vertical-align property cannot be canceled, will your website render appropriately without it? Like by modifying margin, padding, and border?
margin: 1px 1px 1px 1px; (or something similar)....
A very descriptive site for info on those:
http://www.w3.org/TR/CSS21/box.html
And this site for info on baseline and vertical-align:
http://dev.w3.org/csswg/css-text-3/

Please check CSS vertical-align property default
because the default value is baseline anyway.
However, you can remove it from the CSS set,
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video {

Related

CSS Override not working

I understand about CSS specificity (a bit), but I can't seem to understand a problem I am currently having.
I have a CSS Reset file, which I include before any other CSS files in my page. This file contains the following
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, figure, footer, header, hgroup, menu, nav, section, menu, time, mark, audio, video {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border: 0 none;
font-size: 100%;
margin: 0;
outline: 0 none;
padding: 0;
vertical-align: baseline;
}
Then, in my own css file (which is added after the reset), I have the following
ol, ul {
margin-bottom: 20px;
padding-left: 25px;
}
"OL" and "UL" are both single elements in the reset and custom css files - that is, neither of them have any prefix - so I would expect my own css to override the css. For some reason it doesn't.
I have been temporarily appending !important to my custom CSS, but I need to do this for almost every rule I am writing.
What am I missing?

Use CSS to hide all tags but certain ones w/ no ability to add class

I would like to do something like this....
body{
display:none;
}
#signIn_form_section{
display:inline;
}
Of course this does not work but I am looking for something similar. Basically I want to whitelist tags that are allowed to display.
Added html in jfiddle....
Link
Basically I just want the form and non-hidden input fields to show up.
I have created a working CodePen example of how to do this. You need to be specific about the tag, such as section in this example, *:not does not work properly.
HTML:
<section>
<article>
<p>I am hidden</p>
</article>
</section>
<section class="display">
<article>
<p>You can see me</p>
</article>
</section>
CSS:
section:not(.display) {
display: none;
}
You probably mean:
* {
display: none;
}
#signIn_form_section{
display:inline;
}
However, I don't believe this is a good idea... Could you please develop your requirements? Why you need to do so?
You can add a class display to elements that you want to display and do this to hide all the ones that don't have that class:
*:not(.display) {
display: none;
}
However I would question why you want to do this.
It might make more sense to add a class hidden to elements you want to hide and do this instead:
.hidden {
display: none;
}
First Set
div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video { display:none; }
then make a class and set it to display:block; add this class to those elements you want to show.

Missing Rich Text on content WP

This is a question not answered on wordpress.stackoverflow and it won´t be answered cause was placed on hold :(
I have a template made from html to WP, seems to be all was wonking perfectly until I tried to use remarked text with BOLD and Italic text. all text in post is shown FLAT, only shows pre coded color (theme color font).
<div class="property-description">
?php the_content();?>
</div>
CSS
content {
max-width:1000px;
}
.property-description {
color: #777777;
padding: 10px 0 20px 0;
line-height: 1.4em;
}
I have additional lines which no involve the described code, I tried to add a code using .property-description p{} to change paragraph but I have same results.
Is there any code to override prior code. The error should be on css on this theme only.
Best Regards!
I found the problem that makes that Wordpress doesn't show the formatted text. on the style.css I saw a reset line for most style tags; previously I was used this kind of reset to get a nice responsive site but, today was messy the result to display the rich text content. so I decided to delete some tags from this reset line.
the reset lines is this
Reset & Basics (Inspired by E. Meyers)
================================================== */
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video
margin : 0;
padding : 0;
border : 0;
font-size : 100%;
font : inherit;
vertical-align : baseline;
So I delete the tags em, strong, iframe, table and others which were breaking the rich text content; Now my site works perfectly.

why we need to add follow css to every page? [duplicate]

This question already has answers here:
What's the purpose of using CSS browser reset code?
(3 answers)
Closed 9 years ago.
i'm a fresh in css, my friend suggest me to add below css to every page,
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
font-family: arial,sans-serif;
}
why we need do that?
to reset all settings, that might vary among different browsers
examples: http://meyerweb.com/eric/tools/css/reset/
as ExP already explained you should not use this, but a css reset can be very helpful as some browsers display certain elements different from each other (just like jancha said).
But I prefere normalize.css - it does not change the overall behavior of your elements but unifys them as best as possible.
Just load the normalize.css before you load your own css file and everythings fine! :)
http://necolas.github.io/normalize.css/
Actually, you probably don't want to add this to every page.
It makes the font size and margins of all elements look the same. Headings would look exactly like paragraphs without even any space between them...

Firefox default font size issue

Flexible layouts use ems or % as font-size units a common practice is to use body font-size as 62.5%
But Firefox's default font is 14px which results in smaller layout than others who have 16px default font size
Can't we fix just body font-size to 10px so that relative sizes works in every browser.
Also, in addition to #Ray's answer..
For browser inconsitencies like these, consider using a reset stylesheet.
A good one can be found here. and here.
I am pasting the code here for sake of reference.
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
You are saying a lot of the right things here:
Ems and percents have traditionally been the units to use for "scalable" layouts.
The "cascade" in CSS includes the browser's own style sheet. So whenever you omit a style property for some element, it searches through the cascade and will pick up these missing properties from the browser's style sheet at the end of a chain.
If you want pixel-perfect font handling for page text that looks the same across browsers, you will need to define a font-size yourself. Using px on the body element should give you what you want. I'm not aware of any reason why this is still an issue. There was a time when some people would avoid px but modern browsers handle zooming nicely now that I suspect it is much less of an issue than it was.

Resources