CSS Class and Identity Structure / Naming

I have been a web developer for almost 2 years now, and every day I still learn new things, but as my knowledge becomes more and more, I came across some fundamental question and did not find a good discussion about it.

What do you call your div, id, classes? Do you give them specific names related to the content? (i.e. <div id="google_map">)

Or do you call them related to their position on the site? (i.e. <div id="content_top_bar">)

And you do it in your .css the same way?

I hope you get what I'm trying to find out. I think that in any case there is no “true” answer, but I would like to know some opinions so that I can decide which option to take and continue to work with him in the future.

+3
source share
5

HTML , , ( , HTML.

, <div id="left-sidebar">, , , . , a <div id="navigation"> <div id="article">, , .

+6

( ). , , .

, , , , ( , ).

, , , , . jQuery ( ).

+3

, : :)

, :

  • , ?
  • ?

, div "content", , , "div_homepage".

, :)

+2

HTML , .

+1
source

Depending on what the html element represents:

  • An element is part of a layout, call it something that represents this part of the layout. Example:'footer_top_bar'

  • An element is used for specific content, call it something that represents the content. Example:'comment', 'navigation', 'breadcrumbs'.

0
source

All Articles