I want to style a h2 with a specific font size but it doesn't change but if i style it with a color ,the color changed

Dani AI

Generated

Quick troubleshooting notes for based on the thread: if changing color on an h2 takes effect but font-size does not, the stylesheet is applying but some other rule is winning for the font-size. Common causes are cascade/specificity, an inline style on the element, a rule with !important, a CSS reset/framework (as suggested), or use of rem/em with an unexpected root size. and requested code — when asking for help include the h2 HTML, the CSS that targets it, and the order of linked stylesheets or frameworks.

Quick steps to find the culprit:

  • Open browser DevTools, Inspect the h2, and check the Styles and Computed panels to see which rule supplies the final font-size and whether any rules are crossed out.
  • Search your stylesheets for font-size rules targeting h2 (or parent selectors like header h2) and for any !important.
  • Check for inline style attributes or JavaScript that sets styles.
  • If using rem, verify the html font-size; if using a CSS framework, check its heading rules.

If you need a quick override, add a class to the heading and style that class (preferred over !important):

h2.my-title {
  font-size: 32px;
  color: #c00;
}

For details on how CSS decides which rule wins, see CSS Specificity.

please paste the code you are using to do the styling.

Is that possible to change like that. If possible please paste code here

Each font style or size in the websites can be reset with in the CSS which is used in the each type of websites..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.