justamanda / prj-rev-bwfs-dasmoto

0 stars 0 forks source link

Class vs ID #3

Open cyouh95 opened 6 years ago

cyouh95 commented 6 years ago

Consider using IDs for the specific sections instead of classes. For example:

HTML:

<h2 id="brushes">Brushes</h2>

CSS:

#brushes{
  ...
}

https://github.com/justamanda/prj-rev-bwfs-dasmoto/blob/master/Dasmoto/resources/index.css#L20-L28

justamanda commented 6 years ago

We were told to use classes over IDs whenever possible. Would you say there's an advantage to the IDs in this situation?

cyouh95 commented 6 years ago

I think you should definitely use classes when they could be applied to multiple elements, but IDs for the main, unique sections of a page. An advantage of the ID here is that you could add hyperlinks that jump to each section. For example, try changing lines 20, 23, 26 in your CSS file:

#brushes{
  ...
}
#frames{
  ...
}
#paints{
  ...
}

And lines 10, 14, 18 in your HTML file:

<h2 id="brushes">Brushes</h2>
...
<h2 id="frames">Frames</h2>
...
<h2 id="paints">Paints</h2>

Then add this after line 8 of your HTML:

<a href="#brushes">Brushes</a>
<a href="#frames">Frames</a>
<a href="#paints">Paints</a>