Alter css of article?

General questions relating to Joomla! 5.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
SocketPup
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 134
Joined: Thu Mar 14, 2024 7:00 am

Alter css of article?

Post by SocketPup » Mon Apr 01, 2024 3:59 pm

I set a custom css class in one of my Menu items, in order to style the article attached to said menu item. It works in the sense that I can alter background-color, but I can't seem to change css for images and paragraphs. Do I need to set individual classes for the different markups inside the articles somehow?

User avatar
AMurray
Joomla! Exemplar
Joomla! Exemplar
Posts: 9914
Joined: Sat Feb 13, 2010 7:35 am
Location: Australia

Re: Alter css of article?

Post by AMurray » Mon Apr 01, 2024 9:58 pm

No, you don't set up the CSS inside articles, you use a custom CSS file (normally called "user.css" e.g. for Cassiopeia, but it may be called something else like "custom.css" depending on the template you're using.

I'd suggest a few quick lessons in how CSS works. My favourite resource for learning is https://www.w3schools.com/css/

You apply the class name to the element you want to style such as paragraph:

As a simple example

Code: Select all

<p class="yourCSS">content</p>
The code for the CSS itself sits in "user.css" (or other as relevant):

Code: Select all

.yourCSS { margin:10; padding:10; font-weight:bold;font-family:arial;}
Regards - A Murray
General Support Moderator

SocketPup
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 134
Joined: Thu Mar 14, 2024 7:00 am

Re: Alter css of article?

Post by SocketPup » Tue Apr 02, 2024 4:09 am

AMurray wrote: Mon Apr 01, 2024 9:58 pm No, you don't set up the CSS inside articles, you use a custom CSS file (normally called "user.css" e.g. for Cassiopeia, but it may be called something else like "custom.css" depending on the template you're using.

I'd suggest a few quick lessons in how CSS works. My favourite resource for learning is https://www.w3schools.com/css/

You apply the class name to the element you want to style such as paragraph:

As a simple example

Code: Select all

<p class="yourCSS">content</p>
The code for the CSS itself sits in "user.css" (or other as relevant):

Code: Select all

.yourCSS { margin:10; padding:10; font-weight:bold;font-family:arial;}
I know my css, that's not the problem here. The problem is that while I am able to assign a custom css-class to the article, thereby change the background, I can't seem to change any of the elements inside the article (for example p & img)

So, in essence, the following works great:

.about-us {
background-color: blue;
}

BUT, the following does nothing:

.about-us img {
width:300px;
}

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31084
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Alter css of article?

Post by Per Yngve Berg » Tue Apr 02, 2024 6:37 am

What is the Developer Console of your Browser saying?

Is the entry overwritten by other css?

User avatar
Pavel-ww
Joomla! Ace
Joomla! Ace
Posts: 1681
Joined: Tue Jun 30, 2020 12:17 pm

Re: Alter css of article?

Post by Pavel-ww » Tue Apr 02, 2024 10:07 am

SocketPup wrote: Tue Apr 02, 2024 4:09 am .about-us img {
width:300px;
}
Hi. Most likely your selector is not strong enough or not accurate enough. Provide a url


Post Reply

Return to “General Questions/New to Joomla! 5.x”