はい、Eric Meyer のリセットは「正しい方法」の 1 つであり、* を使用するよりもはるかに優れています。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>North Carolina Golf Car Dealers</title>
<style type="text/css">
/* 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;
}
#container {
width: 960px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id="container">
<div id="header">
<h1>Header goes here.</h1>
</div>
<div id="content">
<p>Content goes here</p>
</div>
<div id="footer">
<p>Footer goes here.</p>
</div>
</div>
</body>
</html>
理想的には、外部スタイル シートを使用して HTML と CSS を分離する必要があります。
HTML: index.html (例)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>North Carolina Golf Car Dealers</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="container">
<div id="header">
<h1>Header goes here.</h1>
</div>
<div id="content">
<p>Content goes here</p>
</div>
<div id="footer">
<p>Footer goes here.</p>
</div>
</div>
</body>
</html>
CSS: style.css (例)
@charset "utf-8";
/* CSS Document */
/* 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;
}
#container {
width: 960px;
margin: 0 auto;
}
注: CSS #container を次から変更しました。
#container {
width: 960px;
margin-right: auto;
margin-left: auto
に:
#container {
width: 960px;
margin: 0 auto;
}
margin-right と margin-left を組み合わせる (両方の方法が機能します...)