# How to Override width and height HTML attributes with CSS

DevFeed: [How to Override width and height HTML attributes with CSS](<https://devfeed.tech/articles/how-to-override-width-and-height-html-attributes-with-css-37475.md>)

Original publisher: [Read original article](<https://davidwalsh.name/css-override-width-height>)

Author: David Walsh

Published: 2024-02-05T11:28:01Z

Content type: tutorial

Language: en

Sources: [David Walsh](<https://devfeed.tech/sources/david-walsh.md>)

Topics: [CSS](<https://devfeed.tech/topics/css.md>), [HTML](<https://devfeed.tech/topics/html.md>), [Responsive Design](<https://devfeed.tech/topics/responsive-design.md>), [html elements](<https://devfeed.tech/topics/html-elements.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [css](<https://devfeed.tech/tags/css.md>), [css-html5](<https://devfeed.tech/tags/css-html5.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [html](<https://devfeed.tech/tags/html.md>), [html5](<https://devfeed.tech/tags/html5.md>), [image](<https://devfeed.tech/tags/image.md>), [responsive-design](<https://devfeed.tech/tags/responsive-design.md>)

## AI overview

This tutorial explains how CSS can override HTML width and height attributes for images. It discusses preserving image dimensions for layout performance while using responsive styling to avoid distorted images.

## Source excerpt

One of the HTML elements that frequently comes into collision with CSS is the img element. As we learned in Request Metrics' Fixing Cumulative Layout Shift Problems on DavidWalshBlog article, providing image dimensions within the image tag will help to improve your website's score. But in a world where responsive design is king, we need [...] The post How to Override width and height HTML attributes with CSS appeared first on David Walsh Blog.