The HTML should be validated if you expect it to behave “as expected” in most browsers. https://validator.w3.org/nu/
(1) There is no doctype at the top of the page. That’s a requirement, not an option.
(2) One can apply a preferred language to the <html>
tag like so, <html lang="en">
. At this time, you have no designated language.
(3) One should designate a character set.as the first meta tag in the <head>
section,
<head>
<meta charset="utf-8">
The link to your stylesheet and the title are good. The <head>
tag is properly closed.
(4) The <body>
tag has been assigned a className of “body”. Since there is only one <body>
element on a page, and since properties can be assigned directly to tags with CSS, the addition of a className is unnecessary.
(5) I do not recommend assigning a width to the <body>
element. It should be allowed to extend to the full width of the <html>
. Yes, a width can be assigned to the <body>
element; however there are a few nuances that one must be aware of which can be cumbersome. It is simpler and more flexible to add an .outer
html element such as <div class="outer">
and assign any page width to .outer
. The window background can then be assigned to the <body>
, not the <html>
.outer {
width: ; /* width and unit of measure depend on the design. */
margin: 0 auto; /* as needed */
}
IMO, if you are still convinced that using the <body>
element to set the page width is the way to go, then go for it. Experience is a good teacher either way.
(6) The first div inside the body tag with the className of “cont” is not closed. Validation would have caught that for you. In my revision, it is the second <div>
tag, .outer
is the first. I’m not convinced yet that they are both needed so I am deleting .cont
for the time being.
(7) I have added a <main>
element.below the <header>
in which the .content
and .sidebar
will reside. NOTE that the main
portion of the page with two columns is separate from the header
and footer
containers. <main>
will hold the content and sidebar. Assigning {display:table}
to <main>
will allow the content and the sidebar to reside in two, equal height columns and can be easily combined into one column at narrow widths. {display:flex}
can be used instead of {display:table}
, if you prefer or if the design requires more flexibility than {display:table}
allows…
(8) @font-face should appear at the top of the CSS file so it is loaded early.
(9) The code for the link pseudo-classes should have the same specificity. As you wrote your CSS, .mainheader nav a:link {
will always override a:hover {
, the a:hover
properties will never take effect because .mainheader nav a
outweighs the lone a
.
(10) It is advisable to include the dimensions of images in the HTML using the width and height attributes. Doing so allows the page to reserve that space when the HTML is loading and thus load smoother.
(11) Responsive pages that display on mobile devices are popular nowadays. You do not appear to have given any thought to that. I added a media query so you can get the idea. FYI, using display:flex instead of display:table/table-cells could avoid the need for the media query. It would also allow you to shift the position of the image in the sidebar more easily, if desired.
(12) I’ve reworked some of the padding and margins, especially those involving article
and contents. In fact, I made changes that are not documented here. You’ll have to compare your original code to this code to find all of them.
(13) Cutting edge properties are not guaranteed to work in all browsers. It is a good idea to bookmark and use https://caniuse.com/
(14) In my version of your incomplete page, both img elements have three common CSS properties:
img {
display:block;
width:100%;
height:auto;
}
therefore, they appears only once in the CSS. Other properties unique to each image are targeted via classNames.
(15) Your image shows the first paragraph in <article>
indented. I coded it as shown. If you want all three paragraphs indented, change the CSS selector from
article p:first-of-type::before {
to
article p::before {
(16) Final note. I deleted the empty lines from the HTML and CSS to make it easier to read. I recommend you do the same when coding.
Your page is a work in progess so there are bound to be more questions. You know where to find us.
Apple.html (2.9 KB)
style.css (2.7 KB)