{"id":2950,"date":"2025-05-28T22:34:37","date_gmt":"2025-05-28T22:34:37","guid":{"rendered":"https:\/\/techtrendfeed.com\/?p=2950"},"modified":"2025-05-28T22:34:37","modified_gmt":"2025-05-28T22:34:37","slug":"find-out-how-to-override-width-and-peak-html-attributes-with-css","status":"publish","type":"post","link":"https:\/\/techtrendfeed.com\/?p=2950","title":{"rendered":"Find out how to Override width and peak HTML attributes with CSS"},"content":{"rendered":" \r\n<br><div id=\"main\"><article itemscope=\"\" itemtype=\"http:\/\/schema.org\/Article\">\n<p>One of many HTML parts that incessantly comes into collision with CSS is the <code>img<\/code> aspect. As we realized in <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/davidwalsh.name\/fixing-cumulative-layout-shift-problems-on-davidwalshblog\">Request Metrics&#8217; Fixing Cumulative Format Shift Issues on DavidWalshBlog<\/a> article, offering picture dimensions throughout the <code>picture<\/code> tag will assist to enhance your web site&#8217;s rating. However in a world the place responsive design is king, we&#8217;d like CSS and HTML to work collectively.<\/p>\n\n\n\n<p>Most responsive design model changes are executed through <code>max-width<\/code> values, however if you present a <code>peak<\/code> worth to your picture, you may get a distorted picture.  The purpose ought to at all times be a show photographs in relative dimensions.  So how can we make sure the <code>peak<\/code> attribute does not battle with <code>max-width<\/code> values?<\/p>\n\n\n\n<p>The reply is as simple as <code>peak: auto<\/code>!<\/p>\n\n\n\n<pre class=\"js\">\n\/* assuming any media question *\/\nimg {\n  \/* Make sure the picture does not go offscreen *\/\n  max-width: 500px;\n  \/* Make sure the picture peak is responsive no matter HTML attribute *\/\n  peak: auto;\n}\n<\/pre>\n\n\n\n<p>The dance to please customers and search engines like google and yahoo is at all times a enjoyable steadiness.  CSS and HTML had been by no means meant to battle however in some circumstances they do.  Use this code to optimize for each customers and search engines like google and yahoo!<\/p>\n\n\n\n<div class=\"x x-long x-secondary\">\n    \n    \n    <div class=\"x-secondary-large\">\n    <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/requestmetrics.com\/?utm_source=davidwalsh\" style=\"display:block;\">\n        <img decoding=\"async\" src=\"https:\/\/davidwalsh.name\/demo\/rm_perf_banner-728.min.svg\" style=\"max-width:100%;height:auto;\" alt=\"Request Metrics real user monitoring\" loading=\"lazy\" width=\"728\" height=\"90\"\/>\n    <\/a>\n    <\/div>\n    <div class=\"x-secondary-small\">\n    <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/requestmetrics.com\/?utm_source=davidwalsh\" style=\"display:block;\">\n        <img decoding=\"async\" src=\"https:\/\/davidwalsh.name\/demo\/rm_perf_block_300.min.svg\" style=\"max-width:100%;height:auto;\" alt=\"Request Metrics real user monitoring\" loading=\"lazy\" width=\"300\" height=\"250\"\/>\n    <\/a>\n    <\/div>\n<\/div>\n\n\n\n\n\n<\/article>\n\n<div class=\"article-block\" style=\"min-height:90px\"><div class=\"x x-long x-terciary\" style=\"max-height: none;\">\n  \n    \n    \n<div class=\"x-secondary-large\">\n  <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/requestmetrics.com\/?utm_source=davidwalsh\" style=\"display:block;\">\n    <img decoding=\"async\" src=\"https:\/\/davidwalsh.name\/demo\/rm_perf_banner-728.min.svg\" style=\"max-width:100%;height:auto;\" alt=\"Request Metrics real user monitoring\" loading=\"lazy\" width=\"728\" height=\"90\"\/>\n  <\/a>\n<\/div>\n<div class=\"x-secondary-small\">\n  <a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/requestmetrics.com\/?utm_source=davidwalsh\" style=\"display:block;\">\n    <img decoding=\"async\" src=\"https:\/\/davidwalsh.name\/demo\/rm_perf_block_300.min.svg\" style=\"max-width:100%;height:auto;\" alt=\"Request Metrics real user monitoring\" loading=\"lazy\" width=\"300\" height=\"250\"\/>\n  <\/a>\n<\/div>\n\n  \n\n<\/div>\n<\/div>\n\n\n<div class=\"article-block post-more\" style=\"\u201cclear:both;\u201d\"><ul class=\"post-list small-list\"><li data-url=\"https:\/\/davidwalsh.name\/mozilla-technologies\" itemscope=\"\" itemtype=\"http:\/\/schema.org\/Article\"><span itemscope=\"\" itemtype=\"https:\/\/schema.org\/ImageObject\"><img decoding=\"async\" src=\"https:\/\/togetherjs.com\/images\/site-hero-image@2x.png?preview\" class=\"post-image\" alt=\"5 Awesome New Mozilla Technologies You\u2019ve Never Heard Of\"\/><\/span><div class=\"preview\"><h3 itemprop=\"name\"><a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/davidwalsh.name\/mozilla-technologies\" itemprop=\"url\">5 Superior New Mozilla Applied sciences You\u2019ve By no means Heard\u00a0Of<\/a><\/h3><p>My journey to Mozilla Summit 2013 was unimaginable. \u00a0I&#8217;ve spent a lot time specializing in my challenge that I had overlooked the entire nice work Mozillians had been placing out. \u00a0MozSummit offered the proper reminder of how good my colleagues are and the way a lot&#8230;<\/p><\/div><\/li><li data-url=\"https:\/\/davidwalsh.name\/detect-node-insertion\" itemscope=\"\" itemtype=\"http:\/\/schema.org\/Article\"><span itemscope=\"\" itemtype=\"https:\/\/schema.org\/ImageObject\"><img decoding=\"async\" src=\"https:\/\/davidwalsh.name\/demo\/JavaScriptListImage.png?preview\" class=\"post-image\" alt=\"Detect DOM Node Insertions with JavaScript and CSS Animations\"\/><\/span><\/li><\/ul><\/div><div class=\"article-block post-more\"><ul class=\"post-list small-list\"><li data-url=\"https:\/\/davidwalsh.name\/css-supports\" itemscope=\"\" itemtype=\"http:\/\/schema.org\/Article\"><span itemscope=\"\" itemtype=\"https:\/\/schema.org\/ImageObject\"><img decoding=\"async\" src=\"https:\/\/davidwalsh.name\/demo\/css3logo250.jpg?preview\" class=\"post-image\" alt=\"CSS @supports\"\/><\/span><div class=\"preview\"><h3 itemprop=\"name\"><a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/davidwalsh.name\/css-supports\" itemprop=\"url\">CSS\u00a0@helps<\/a><\/h3><p>Characteristic detection through JavaScript is a shopper aspect finest observe and for all the proper causes, however sadly that very same performance hasn&#8217;t been out there inside CSS. \u00a0What we find yourself doing is repeating the identical properties a number of occasions with every browser prefix. \u00a0Yuck. \u00a0One other factor we&#8230;<\/p><\/div><\/li><li data-url=\"https:\/\/davidwalsh.name\/mootools-accordion-print\" itemscope=\"\" itemtype=\"http:\/\/schema.org\/Article\"><span itemscope=\"\" itemtype=\"https:\/\/schema.org\/ImageObject\"><img decoding=\"async\" src=\"https:\/\/davidwalsh.name\/demo\/accordion\/let-it-be.jpg?preview\" class=\"post-image\" alt=\"Printing MooTools Accordion Items\"\/><\/span><div class=\"preview\"><h3 itemprop=\"name\"><a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/davidwalsh.name\/mootools-accordion-print\" itemprop=\"url\">Printing MooTools Accordion\u00a0Gadgets<\/a><\/h3><p><a rel=\"nofollow\" target=\"_blank\" href=\"https:\/\/davidwalsh.name\/demo\/accordion-print.php\"\/>&#13;&#13;Typically we&#8217;re offered with unexpected issues in terms of our JavaScript results.  On this case, I am speaking about printing jQuery and MooTools accordions.  Every &#8220;closed&#8221; accordion content material aspect has its peak set to 0 which implies it will likely be hidden when the&#8230;<\/p><\/div><\/li><\/ul><\/div><\/div>\r\n<br>\r\n","protected":false},"excerpt":{"rendered":"<p>One of many HTML parts that incessantly comes into collision with CSS is the img aspect. As we realized in Request Metrics&#8217; Fixing Cumulative Format Shift Issues on DavidWalshBlog article, offering picture dimensions throughout the picture tag will assist to enhance your web site&#8217;s rating. However in a world the place responsive design is king, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2952,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[2847,1147,2846,2092,2844,2845],"class_list":["post-2950","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-attributes","tag-css","tag-height","tag-html","tag-override","tag-width"],"_links":{"self":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/2950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2950"}],"version-history":[{"count":1,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/2950\/revisions"}],"predecessor-version":[{"id":2951,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/2950\/revisions\/2951"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/media\/2952"}],"wp:attachment":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<!-- This website is optimized by Airlift. Learn more: https://airlift.net. Template:. Learn more: https://airlift.net. Template: 69d9690a190636c2e0989534. Config Timestamp: 2026-04-10 21:18:02 UTC, Cached Timestamp: 2026-05-14 18:05:32 UTC -->