How to remove automatic margin I searched it on the internet but every page says margin:0 but that doesnt work for me - margin

The margin doesnt want to be removed idk what to do margin:0 doesn't work thanks for helping
mypage

You should use reset.css in every project.
Create a new css file like reset.css and add in your project
In that css file, save this css:
Reference: https://meyerweb.com/eric/tools/css/reset/
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;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

Related

What the reason of "font" and "content" overwriting in Eric Meyer's reset.css?

Original CSS rules written by Eric Meyer:
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;
}
Here are two overwritings:
font: inherit; overwrites font-size: 100%;
content: none overwrites content: ''.
In the moders IDE with code quality control tools, below warnings will be annoy:
What the reason of this overwritings?
I suppose we may below corrections:
Currently Internet Explorer 7 does not supported anywhere. So, the font: inherit; will be enough without font-size: 100%;
Value '' for content property supported everywhere where :after and :before supported. So, we don't need content: none.

Text width different across browsers

For a reason I need to get the width of the text. When I use offsetWidth, clientWidth or getBoundingClientRect, I do have differences in calculating the width of the text across different browsers, mainly in Edge.
I tried the following:
demo
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;
}
body {
line-height: 1;
}
h1 {
display: inline-block;
font-size: 38px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
<h1>Welk woord is onderstreept?</h1>
<script>
var h1 = document.getElementsByTagName("h1")[0];
document.write(h1.offsetWidth);
</script>
It doesn't matter which font I use. Does anyone knows a proper solution to have the same width of text in every browser?

<nav> element doesn't show top padding

I am designing a website using HTML5 elements. With the following HTML5 and CSS code, there is some abnormality with the top padding for the menus.
/* CSS Resets */
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;
}
/* CSS Resets end */
/* CSS document starts */
body {
background-color: #e4deaf;
margin: 0;
padding: 0;
}
nav {
display: block;
}
a {
text-decoration: none;
color: #808080;
border: 1px dashed black;
border-radius: 7px;
padding: 1em 3em;
}
a:hover {
background-color: #ffbc6a;
}
a:active {
background-color: #e4deaf;
}
<nav>
Menu 1
Menu 2
Menu 3
</nav>
This is the output screenshot:
What is wrong with the padding of the menus?
It's because of the inline default value of display property on a elements. Try to change with inline-block and it works.
/* CSS Resets */
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;
}
/* CSS Resets end */
/* CSS document starts */
body {
background-color: #e4deaf;
margin: 0;
padding: 0;
}
nav {
display: block;
}
a {
text-decoration: none;
color: #808080;
border: 1px dashed black;
border-radius: 7px;
padding: 1em 3em;
display: inline-block;
}
a:hover {
background-color: #ffbc6a;
}
a:active {
background-color: #e4deaf;
}
<nav>
Menu 1
Menu 2
Menu 3
</nav>

How to reset a CSS property [duplicate]

This question already has answers here:
Reset CSS display property to default value
(8 answers)
Closed 8 years ago.
Is there any way to reset a CSS property to its standart value without knowing the value itself?
I have already tried font-size: reset; but that doesn't work.
Thanks!
Use Eric Meyer CSS Reset.
Here is the code:
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
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;
}

how can i use browser sniffing in html through javascript?

i'm having a web page including HTML, CSS, javascript code, The problem is that when i use internet explorer then the divisions and margins of web page is got changed, but its working fine in any other browser..
so can anybody help me regarding this issue..???
Oh good god don't browser sniff UA's! use a lib like this:
http://www.modernizr.com/
Feature detection is what you want not browser sniffing :)
If it's just styling then use a CSS Reset:
http://meyerweb.com/eric/tools/css/reset/
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
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;
}
There's not much a CSS Reset can't solve, bad margins, padding. font-sizes, world hunger, cancer, it's all in there.

Resources