0

The class I want to change has a space in the beginning, see image.

css class question

Does anyone know how to find that class or override it with my own class attributes?

Does . nav { css here } work?

1
  • Please avoid posting screen shots unless you need to show rendered images/html as part of the context. If you need to share text/code, please copy-paste the actual text. meta.stackoverflow.com/a/285557/2943403 Search engines have an easier time reading text than images. Feb 7, 2019 at 5:17

2 Answers 2

0

An element can have multiple classes, separated by a space. Leading and trailing spaces mean nothing. So the class in this case is nav and the selector is .nav.

4

CSS classes and IDs never start with spaces, and they also never have spaces in the middle of it as well.

As Sharky commented, an element can have multiple classes, and those classes must be separated by a space. But keep in mind that an element can have only one ID.

Here is one example:

<div id="mydiv" class="nav menu navbar-collapse">

When a CSS class is added to an element, as above, you must not use the dot. Same is valid for IDs, where you must not use the # symbol when adding it to the element itself.

On the other hand, when adding the styles to your CSS file, you must use the dot for classes, and # for IDs.

Example of class:

.nav {
    background: #f1f1f1;
    color: #58535b;
}

Example of ID:

#mydiv {
    padding: 10px;
}

Joomla, or at least most templates, had, for many years, a problem with the class suffix area/field, where, in most cases, you had to add a space before the first class to avoid problems (because there was no space in the PHP code that loaded the class).

So, for older templates, or older versions of Joomla, you are likely to see the class attribute starting with a space. This is completely harmless, and you can safely ignore it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.