From 5ac8b604faa6acc318d22ace09a9b4f639ac36cb Mon Sep 17 00:00:00 2001 From: Tony Ruscoe Date: Thu, 13 Jan 2022 14:03:19 +0000 Subject: [PATCH] Move the ID and Class Name sections to be together This change was made to the internal style guide a while ago to make it easier to find related sections also containing IDs and class name guidance. --- htmlcssguide.html | 70 +++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/htmlcssguide.html b/htmlcssguide.html index 8293303..d332787 100644 --- a/htmlcssguide.html +++ b/htmlcssguide.html @@ -530,6 +530,41 @@ understandability and code efficiency.

.author {} +

ID and Class Name Delimiters

+ +

Separate words in ID and class names by a hyphen.

+ +

Do not concatenate words and abbreviations in selectors by any characters +(including none at all) other than hyphens, in order to improve understanding +and scannability.

+ +
/* Not recommended: does not separate the words “demo” and “image” */
+.demoimage {}
+
+/* Not recommended: uses underscore instead of hyphen */
+.error_status {}
+
+ +
/* Recommended */
+#video-id {}
+.ads-sample {}
+
+ +

Prefixes

+ +

Prefix selectors with an application-specific prefix (optional).

+ +

In large projects as well as for code that gets embedded in other projects or on +external sites use prefixes (as namespaces) for ID and class names. Use short, +unique identifiers followed by a dash.

+ +

Using namespaces helps preventing naming conflicts and can make maintenance +easier, for example in search and replace operations.

+ +
.adw-help {} /* AdWords */
+#maia-note {} /* Maia */
+
+

Type Selectors

Avoid qualifying ID and class names with type selectors.

@@ -614,41 +649,6 @@ color: #eebbcc; color: #ebc; -

Prefixes

- -

Prefix selectors with an application-specific prefix (optional).

- -

In large projects as well as for code that gets embedded in other projects or on -external sites use prefixes (as namespaces) for ID and class names. Use short, -unique identifiers followed by a dash.

- -

Using namespaces helps preventing naming conflicts and can make maintenance -easier, for example in search and replace operations.

- -
.adw-help {} /* AdWords */
-#maia-note {} /* Maia */
-
- -

ID and Class Name Delimiters

- -

Separate words in ID and class names by a hyphen.

- -

Do not concatenate words and abbreviations in selectors by any characters -(including none at all) other than hyphens, in order to improve understanding -and scannability.

- -
/* Not recommended: does not separate the words “demo” and “image” */
-.demoimage {}
-
-/* Not recommended: uses underscore instead of hyphen */
-.error_status {}
-
- -
/* Recommended */
-#video-id {}
-.ads-sample {}
-
-

Hacks

Avoid user agent detection as well as CSS “hacks”—try a different approach