Adjusting font size in CSS for HTML websites

Having some trouble adjusting the font size on my HTML webpage using CSS - for some reason, the "font-size" property isn't cooperating:

Below is the snippet of HTML code for my site:

And here's a brief look at the accompanying CSS code:

I've added an image of my actual website with text appearing much smaller than expected despite setting the font-size to 200px:

EDIT: No problem, here's the full code:

HTML CODE:

<!DOCTYPE html>
<html lang="en">

<head>
    <title> Flexbox in HTML</title>
    <link rel="stylesheet" href="flexbox.css">

</head>

<body>
    <div class="outer">
        <div class="inner">
            <img src="/images/dog1.jpg"
            <p>This is dog 1</p>
        </div>
        <div class="inner">
            <img src="/images/dog2.jpg"
            <p>This is dog 2</p>
        </div>
        <div class="inner">
            <img src="/images/dog3.jpg"
            <p>This is dog 3</p>
        </div>
        <div class="inner">
            <img src="/images/dog4.jpg"
            <p>This is dog 4</p>
        </div>
    </div>
</body>
</html>

CSS CODE:

.outer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
}

.inner img {
    height:50vh;
}

p {
    text-align:center;
    font-size: 5000%;
}

Answer №1

Your img tags are missing closing brackets, causing your p tags to be invalid. Make sure to add a > at the end of each image tag:

.outer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
}

.inner img {
  height: 50vh;
}

p {
  text-align: center;
  font-size:20px;
}
<div class="outer">
  <div class="inner">
    <img src="/images/dog1.jpg"><p>This is dog 1</p>
  </div>
  <div class="inner">
    <img src="/images/dog2.jpg"><p>This is dog 2</p>
  </div>
  <div class="inner">
    <img src="/images/dog3.jpg"><p>This is dog 3</p>
  </div>
  <div class="inner">
    <img src="/images/dog4.jpg"><p>This is dog 4</p>
  </div>
</div>

Answer №2

Ensure that your image tag is properly closed. If you want to customize the font size in your HTML elements, utilize CSS selectors like classes, IDs, grouping, and universal selectors.

For instance: Using a CSS class for a paragraph element.

  1. Demo.html

     <div class="inner">
         <img src="/images/dog1.jpg">
         <p class="paragraph-font">This is dog 1</p>
     </div>
    
  2. Style.css

    .paragraph-font {
          font-size: 50px;
          }
    

To sum up, using CSS selectors allows you to apply different font sizes based on your needs. For further information, visit this website:

Website link:- https://www.w3schools.com/css/css_selectors.asp

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The implementation of jQuery within an included HTML file may not function properly

I'm looking to implement the use of includes for generic HTML elements in my project. However, I've run into an issue where including an HTML file causes jQuery to stop working. Here is a snippet of my code that illustrates the problem. Specifica ...

The image is not appearing on mobile devices, but it is displaying correctly on desktop computers

Having trouble with my landing page on compare.comxa.com. When I try to view it on my Android device, only the form shows up and the background image is nowhere to be found. Can anyone help me troubleshoot this issue? Here is the code: ...

When I click the button, I would like the value of the button to be displayed in a textbox

I'm currently working on an interactive virtual keyboard project and need help with a function that will display the pressed button values in a text box located next to the keyboard. Here is the code snippet I've come up with so far: <script ...

Tips for adding a border-bottom a few pixels underneath a list item:

I'm working with a menu that has dynamic content. When a user clicks on a li tag, it receives the class "active". I want to show which class is active by adding a border-bottom to it, but I want the border-bottom to be positioned 5px under the li tag ...

Greek symbols do not display correctly in SQL Server when accessed through PHP

At my server database, there is a table with collation set to greek_ci_ai, but I am facing an issue where Greek characters are displaying as question marks(????). I have attempted using header("Content-Type: text/html; charset=iso-8859-7") and <meta ...

What Could Be Causing My Webfonts to Be Inaccessible on Windows Devices and iPhones?

I recently created a simple holding page on www.tomrankinmusic.com The Webfonts I embedded in the page display correctly in the latest versions of Firefox, Safari, and Chrome on Mac OSX Lion 10.7.4 but do not show up in Chrome and IE6 on Windows XP Pro, d ...

Looking for a way to connect a background image in Vue CLI?

When running the code below, I encounter an issue. The code runs properly but the images are not displaying and instead showing the URL as unknown. How can I fix this problem? The images definitely exist. <template> <div class="slider">< ...

What is the best way to iterate through a subdirectory using Jekyll?

Currently utilizing Jekyll, I've organized my project with a folder named "articles" at the root. Inside this folder, there are two subfolders: "fr" and "eng". My objective is to loop through the "fr" folder on one page and the "eng" folder on anothe ...

Ways to enable file/result downloads on a website using HTML

Could you please take a look at this repository: https://github.com/imsikka/ArtGallery I am looking to create a downloadable result using a download button. I can create the button, but I am unsure of how to make the file actually downloadable. Do I need ...

Having difficulty configuring Compass in WebStorm

Trying to integrate Compass into an existing WebStorm project has been challenging for me as the CSS files are not linking properly. Despite my efforts to modify the relative links, I have not yet managed to resolve the issue. The folders and config.rb we ...

jQuery Super-sized Not Expanding Vertically

I am facing an issue with resizing a 1920x1200 background image using jQuery Supersized. Whenever I resize the browser, there is a gap that appears vertically instead of filling up to compensate for the width constraint. I have checked and copied the sett ...

What is the best way to navigate a carousel containing images or divs using arrow keys while maintaining focus?

Recently, I have been exploring the Ant Carousel component which can be found at https://ant.design/components/carousel/. The Carousel is enclosed within a Modal and contains multiple child div elements. Initially, the arrow keys for navigation do not work ...

Aligning the text in the left div vertically based on the right div's position

I am currently working on aligning two parallel div boxes, each containing text. The width of these div boxes is not fixed and changes based on a percentage. My challenge is to make the text in the left div box start at the same position as a heading in th ...

Sending Files via PHP Email Attachment

I've been working on creating a customized contact form that allows users to attach a photo using PHP mail. The goal is to send the photo to the specified recipient indicated in the PHP mail code. <input type="file" id="file" name="file"> Belo ...

What causes images to expand automatically when selected in my JavaScript gallery?

I am struggling with a simple JS gallery of images where I want to display a large image at the top and small thumbnails below it. The issue I am facing is that when I hover over an image in the thumbnail section, the big image changes as expected. However ...

Getting URL parameters dynamically without reloading the page

Here's a particular issue I'm encountering: I've implemented the following function to fetch the GET Parameters from a URL. $(document).ready(function() { function getParam(variable) { var query = window.location.search.sub ...

List items are loaded dynamically in an unordered fashion

I have been working on a jquery slider using flickerplate. Below is the code that works when the values are hardcoded: <div class="flicker-example"> <ul> <li data-background="lib/flicker-1.jpg"> <div class ...

Using jQuery to Fade Out a DIV from multiple dropdown menus

Is there a way to fadeout the ".checkbox10" DIV only if ALL THREE of these dropdowns are reverted back to the original ("None") selection? Any help would be appreciated. Thank you. *I have successfully implemented thisDIV fadeIn() using "change" whenever ...

Generating a dynamic method for uploading multiple files

Is there a way to dynamically generate multiple upload forms upon clicking a button? I currently have code that allows for uploading one file, but I would like to be able to add additional forms for each file. In other words, if I need to upload 7 files, I ...

Unable to retrieve list using Selenium in C# due to issues with FindElements method

Currently, I am working with C# and NUnit. I have encountered an issue where I need to extract the value from a span element and store it in an ArrayList. This is the code I am using to retrieve the price list: var productprice = driver.FindElements(By. ...