{"id":4023,"date":"2026-11-09T11:20:55","date_gmt":"2026-11-09T10:20:55","guid":{"rendered":"https:\/\/nadiapereira.pt\/?p=4023"},"modified":"2026-11-09T11:53:47","modified_gmt":"2026-11-09T10:53:47","slug":"um-pouco-de-html-e-css-que-qualquer-pessoa-com-wordpress-devia-conhecer","status":"publish","type":"post","link":"https:\/\/nadiapereira.pt\/en\/um-pouco-de-html-e-css-que-qualquer-pessoa-com-wordpress-devia-conhecer\/","title":{"rendered":"A little HTML and CSS that everyone with a WordPress site should know"},"content":{"rendered":"<div class=\"wp-block-stackable-image stk-block-image stk-block stk-6bb2ed5\" data-block-id=\"6bb2ed5\"><style>.stk-6bb2ed5 {margin-bottom:50px !important;}.stk-6bb2ed5 .stk-img-wrapper{aspect-ratio:3\/1 !important;height:auto !important;}.stk-6bb2ed5 .stk-img-wrapper img{object-position:40% 59% !important;}@media screen and (max-width:999px){.stk-6bb2ed5 .stk-img-wrapper{height:auto !important;}}@media screen and (max-width:689px){.stk-6bb2ed5 .stk-img-wrapper{height:auto !important;}}<\/style><figure><span class=\"stk-img-wrapper stk-image--shape-stretch\"><img loading=\"lazy\" decoding=\"async\" class=\"stk-img wp-image-4025\" src=\"https:\/\/nadiapereira.pt\/wp-content\/uploads\/2026\/11\/pexels-dkomov-34803976.jpg\" width=\"1920\" height=\"1280\" srcset=\"https:\/\/nadiapereira.pt\/wp-content\/uploads\/2026\/11\/pexels-dkomov-34803976.jpg 1920w, https:\/\/nadiapereira.pt\/wp-content\/uploads\/2026\/11\/pexels-dkomov-34803976-300x200.jpg 300w, https:\/\/nadiapereira.pt\/wp-content\/uploads\/2026\/11\/pexels-dkomov-34803976-1024x683.jpg 1024w, https:\/\/nadiapereira.pt\/wp-content\/uploads\/2026\/11\/pexels-dkomov-34803976-768x512.jpg 768w, https:\/\/nadiapereira.pt\/wp-content\/uploads\/2026\/11\/pexels-dkomov-34803976-1536x1024.jpg 1536w, https:\/\/nadiapereira.pt\/wp-content\/uploads\/2026\/11\/pexels-dkomov-34803976-18x12.jpg 18w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/span><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">You can have a lovely WordPress site without ever opening a code editor, but sooner or later you hit that one small thing the theme will not let you change: a button that does not stand out, a gap that is too big, an element that should disappear on mobile. Calling someone in over five lines of code is hardly practical, and <strong>understanding the basics of HTML and CSS<\/strong> solves almost all of it. You will not become a developer, but you will know enough to make changes safely.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Where to write your CSS without breaking anything<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The first rule is never to edit the main theme's files, because an update will wipe your changes. There are four safe places, and the right one depends on your theme (according to <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/www.hostinger.com\/ca\/tutorials\/wordpress-custom-css\/\">Hostinger's guide<\/a>):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Classic theme:<\/strong> <em>Appearance \u2192 Customise \u2192 Additional CSS<\/em>. It is the quickest option, but the CSS is stored with the active theme and disappears if you switch.<\/li>\n\n\n\n<li><strong>Block theme:<\/strong> <em>Appearance \u2192 Editor \u2192 Styles \u2192 Additional CSS<\/em>You give the block a class, under <em>Advanced \u2192 Additional CSS class(es)<\/em>, and style that class.<\/li>\n\n\n\n<li><strong>Child theme:<\/strong> the CSS goes in the child theme's <code>style.css<\/code> , which survives updates to the parent theme. It is the most professional route.<\/li>\n\n\n\n<li><strong>\u2022 Snippets plugin (such as WPCode):<\/strong> the CSS is independent of the theme and stays put if you change it.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Menu names can vary slightly with your WordPress version and language. And if you have changed some CSS and nothing happens, clear the cache first: in your browser, in your caching plugin and on the server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The most useful tool: the browser inspector<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you write a single line of CSS, you need to know <strong>what<\/strong> you want to change. Right-click the element and choose <em>Inspect<\/em> (in Chrome, Edge, Firefox or Safari). A panel opens showing the page's HTML, with the element you chose highlighted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From there you get two things: the element's <strong>classe<\/strong> class (for example, <code>wp-block-button__link<\/code>and the styles already applied to it. You can edit those values right there and see the result in real time without breaking anything, because nothing is saved. Once you like the result, you copy the rule to the right place in WordPress. This saves more time than any tutorial: instead of guessing, you test.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Five tweaks that solve common problems<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. Hide an element on mobile.<\/strong> Give the block the class <code>hide-on-mobile<\/code> (em <em>Advanced \u2192 Additional CSS class(es)<\/em>and add:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@media (max-width: 768px) {\n  .esconder-telemovel {\n    display: none;\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Bring buttons to life with a gentle hover.<\/strong> A button that reacts to the mouse looks more polished:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.wp-block-button__link {\n  transition: background-color 0.2s ease, transform 0.2s ease;\n}\n.wp-block-button__link:hover {\n  transform: translateY(-2px);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Smooth scrolling for anchor links.<\/strong> Handy on long pages with an in-page menu. I always wrap it in a condition so it respects people who have switched off animations in their system settings, which is an accessibility matter:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@media (prefers-reduced-motion: no-preference) {\n  html {\n    scroll-behavior: smooth;\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>4. Images with the same proportions.<\/strong> In card grids, images of different heights spoil the alignment. With <code>aspect-ratio<\/code> and <code>object-fit<\/code> they all match, without distortion:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.cartao img {\n  width: 100%;\n  aspect-ratio: 4 \/ 3;\n  object-fit: cover;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>5. Fix sideways scrolling on mobile.<\/strong> If the page \u201cescapes\u201d to the side, some element is wider than the screen. Use the inspector to track it down. If you cannot find it, this temporary remedy usually does the job:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>body {\n  overflow-x: clip;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Prefer <code>clip<\/code> to <code>hidden<\/code>, because it does not interfere with fixed or <em>sticky<\/em>But it is a quick plaster: the proper fix is to correct the element causing the problem.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">And a little HTML<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">HTML is the structure of the page, and WordPress handles most of it for you. But there are four things worth knowing:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Heading hierarchy.<\/strong> Each page should have a single <code>&lt;h1&gt;<\/code>, followed by <code>&lt;h2&gt;<\/code> for sections and <code>&lt;h3&gt;<\/code> for subsections, with no skipped levels. It helps SEO and anyone using a screen reader. Do not pick a heading just because it is the size you want: the level is structure, the size is style.<\/li>\n\n\n\n<li><strong>Anchors.<\/strong> To create a link that jumps to a section of the same page, give the block an HTML anchor (under <em>Advanced<\/em>), for example <code>contacts<\/code>, and link to <code>#contacts<\/code>.<\/li>\n\n\n\n<li><strong>Alt text.<\/strong> Describe each image with useful information, and leave the field empty for purely decorative ones, so screen readers skip them.<\/li>\n\n\n\n<li><strong>External links.<\/strong> If you open a link in a new tab (<code>target=\"_blank\"<\/code>), add <code>rel=\"noopener\"<\/code>. WordPress usually takes care of this when you tick \u201cOpen in new tab\u201d, but it is worth checking in the code.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Good practice and pitfalls<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When your CSS \u201cdoes not work\u201d, it is almost always for one of these reasons:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Specificity.<\/strong> If another, more specific rule already applies to the element, yours loses. Instead of reaching straight for <code>!important<\/code>, make your selector more specific (for example, <code>.card .wp-block-button__link<\/code>). Keep <code>!important<\/code> as a last resort.<\/li>\n\n\n\n<li><strong>Cache.<\/strong> Before you doubt the code, clear the cache in your browser, in your caching plugin and on the server.<\/li>\n\n\n\n<li><strong>Changing classes.<\/strong> Avoid basing your CSS on classes generated automatically by plugins or page builders, because they can change in an update. Create your own, with clear names.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">And three habits that will save you some nasty surprises: back up your CSS before touching it (just paste it into a text file), comment what each block does, and always test on mobile and in a second browser. With that, and the inspector open, most small tweaks stop being a problem and become five minutes\u2019 work.<\/p>","protected":false},"excerpt":{"rendered":"<p>Podes ter um site WordPress bonito sem nunca abrir um editor de c\u00f3digo, mas mais cedo ou mais tarde surge aquela coisa pequena que o tema n\u00e3o deixa mudar: um bot\u00e3o que n\u00e3o se destaca, um espa\u00e7o a mais, um elemento que devia desaparecer no telem\u00f3vel. Chamar algu\u00e9m por causa de cinco linhas de c\u00f3digo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62,58],"tags":[],"class_list":["post-4023","post","type-post","status-publish","format-standard","hentry","category-html-css","category-web-design"],"_links":{"self":[{"href":"https:\/\/nadiapereira.pt\/en\/wp-json\/wp\/v2\/posts\/4023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nadiapereira.pt\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nadiapereira.pt\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nadiapereira.pt\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nadiapereira.pt\/en\/wp-json\/wp\/v2\/comments?post=4023"}],"version-history":[{"count":2,"href":"https:\/\/nadiapereira.pt\/en\/wp-json\/wp\/v2\/posts\/4023\/revisions"}],"predecessor-version":[{"id":4028,"href":"https:\/\/nadiapereira.pt\/en\/wp-json\/wp\/v2\/posts\/4023\/revisions\/4028"}],"wp:attachment":[{"href":"https:\/\/nadiapereira.pt\/en\/wp-json\/wp\/v2\/media?parent=4023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nadiapereira.pt\/en\/wp-json\/wp\/v2\/categories?post=4023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nadiapereira.pt\/en\/wp-json\/wp\/v2\/tags?post=4023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}