Shrinking my content on mobile devices with the use of "<p>" tag

I've noticed my footer, header, and forms shrink on mobile devices, but the text on my privacy pages remains the same size. Is there an easy way to make this text shrink as well? Thank you

.content {
border: 1px solid transparent;
margin: auto;
margin-top: 40px;
padding: 50px 0px 50px 0px;
width: 1000px;
}

.content a {
color: #0996f8;  
font-family: Sans,Helvetica,Arial,sans-serif;
font-size: 17px;
font-weight: 300;
line-height: 28px;
text-decoration: none;
}

.content a:hover {
color: #0996f8;  
font-family: Sans,Helvetica,Arial,sans-serif;
font-size: 17px;
font-weight: 300;
line-height: 28px;
text-decoration: underline;
}

.content p {
color: #221f1f;  
font-family: Sans,Helvetica,Arial,sans-serif;
font-size: 17px;
font-weight: 300;
line-height: 28px;
}

Answer №1

There are various methods to reduce the size of the content on a webpage.

First option: Implementing @media rules

By using @media rules, you can alter the CSS based on the screen's width or height. This allows you to adjust the font size to fit the screen or decrease the overall size of the content by adjusting the width of the paragraph element.

An example of CSS with @media rules would be:

@media only screen and (max-width 767px){.content p{font-size: 14px;}}

You can apply any other CSS settings within @media rules as mentioned above.

Second option: Setting a width for the paragraph and utilizing word-break property

While not as effective as using @media rules, setting a specific width for the paragraph element or its parent, along with using word-break property, can help ensure that when the content overflows, it moves to a new line. Utilizing 'word-break: break-word;' ensures that the content breaks at whole words rather than individual letters.

Answer №2

To prevent any conflicts with mobile CSS, it's important to remove duplicate properties already declared in '.content p' from other classes.

One way to ensure the font size adjusts properly is to add a CSS media query below the '.content p' class that detects the browser width and updates the font size accordingly.

@media screen and (max-width: 600px) {
.content p {  
font-size: /* Enter new font size */; 
}
}

By implementing this, the font size will automatically adjust when the browser width is less than 600px.

Answer №3

Are you looking to reduce the content size on smaller screens? One way to easily achieve this is by using the rem unit and CSS media queries to adjust the font size property on the HTML tag, which will then cascade down to all other elements.

If you need some reference breakpoints, check out this resource on common responsive breakpoints in 2017. Remember to explore additional sources for device-specific breakpoints.

.content {
  border: 1px solid transparent;
  margin: auto;
  margin-top: 40px;
  padding: 50px 0px 50px 0px;
  width: 1000px;
}

.content a {
  color: #0996f8; 
  font-family: Sans, Helvetica, Arial, sans-serif;
  font-weight: 300;
  line-height: 28px;
  text-decoration: none;
}

... (remaining CSS code unchanged) ...
<div class="content">
  <h2>Title 1</h2>
  ... (remaining HTML content unchanged) ...
</div>

Alternatively, you can utilize CSS Variables along with media queries to dynamically update variables for different screen sizes. This approach allows for more flexibility in customizing sizes based on specific breakpoints, though it may introduce some complexity.

Here's a basic example, but I recommend researching further about CSS Variables for a better understanding.

:root {
    --font-size: 16px;
}

.item { 
    font-size: var(--font-size);
}

@media (max-width: 400px) {
    :root {
        --font-size: 14px;
    }
}

Answer №4

To effectively target specific screen sizes, utilize css media queries to adjust styling at different breakpoints. Here is an example:

@media (min-width: 768px){
    .content p{
        font-size: 12px;
    }
}
@media (min-width: 992px){
    .content p{
        font-size: 14px;
    }
}
@media (min-width: 1200px){
    .content p{
        font-size: 16px;
    }
}

When starting a new website development project, it is recommended to establish a comprehensive style sheet that covers various elements like headings, paragraphs, links, lists, etc. Avoid directly styling paragraph tags across the site; instead, control their appearance from a centralized location.

By maintaining consistent styles and implementing changes in one place, managing updates becomes more efficient. For instance, on a large website with numerous pages, modifying the paragraph size can be easily achieved by making adjustments once, adhering to the DRY (Don't Repeat Yourself) principle.

If you need to apply different font sizes while keeping styles contained, consider grouping styles within encapsulated classes. For example, if your standard paragraph tag size is 16px but you want larger text in the header and footer sections, use a similar approach as shown below:

@media (min-width: 1200px){
    .header p,
    .footer p{
        font-size: 21px;
    }
}

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

Utilizing functions for object creation in JavaScript

Having trouble with creating a function that automatically generates an object and then alerts its properties. Can't seem to get the alerts when I click the button. Any assistance would be appreciated. <html> <head> <s ...

Can you explain the purpose of the text-align property set to justify-all?

Can you explain what the CSS property text-align: justify-all does? According to MDN, it should justify even the content of the last line. However, I am not seeing any changes in my Chrome browser: <p style="text-align: justify-all"> one two thre ...

developing a segment within an HTML document

Recently, I came across a fascinating website at . I was particularly intrigued by the way the right and left columns expand and contract dynamically when clicked. As someone new to web development, especially in terms of dynamic websites using jQuery, I ...

Pictures do not adhere to the maximum width set on their parent elements

When the max-width CSS style is set on the body tag and an image within the body surpasses this maximum width, the image does not adhere to the set limit. Instead of resizing, it simply overflows. Why does this happen? So, what is the solution to this pro ...

I would like the dropdown menu to only appear on mobile devices

After creating a dropdown menu, I now want it to only appear in mobile view and not in other views. I believe this can be achieved using "visible-xs" or a similar method, but I am struggling with the coding. Below is my HTML code: <nav class="navb ...

My React project is not showing the text in the way that I had envisioned

When using the Material UI TextInput component with a placeholder prop set to display the text "Contraseña", I encountered an issue where the letter ñ was not rendering correctly and instead showing as \fx1. My HTML head section includes m ...

WordPress Header Display Issue on Mobile and Tablet Devices: What You Need to Know

I'm facing an issue with the header and footer being cut off on mobile devices. When viewed on a tablet or phone, the header doesn't display across the full width of the screen. This problem arises because the Wordpress theme was created in 2010 ...

Hide the <footer> element unless there is extra space

I am trying to create a footer that only appears when the viewer has scrolled to the bottom of the page. This means that if you haven't reached the bottom yet, the footer is not visible. The concept seems simple enough, but as I am still in the learni ...

Obtain Vue component reference using the @click event

I've been struggling to find an HTML reference to the component triggering an @click event in Vue. I have a custom component within a list: <ion-list lines="none" v-for="item in uiPosts" :key="item.createdAt"> < ...

Can JavaScript be used to upload a file directly to memory for processing before transferring it to the server?

I'm exploring the idea of using a JavaScript encryption library (not Java) to encrypt a file before sending it to the server. Is it feasible to perform this process on the client-side and then upload the encrypted file using JavaScript, storing it in ...

Clarity of visual in a lattice

I'm encountering a small issue with my ExtJS 4.2 MVC application that involves grid and image transparency. Below is a snippet of my grid setup: Ext.define('XProject.view.message.inbox.Grid', { extend: 'Ext.grid.Panel', al ...

JQuery Mobile: Styling does not apply to dynamically populated Select elements

I've been struggling to apply jQuery Mobile styles to a select element that is dynamically filled. Even after attempting to add themes, manual styles, refreshing, $('.ui-page-active').trigger('create');, and more, I still can' ...

photos arranged in rows rather than a single row

Looking for help with arranging the remaining photos in the second row? Check out this example image link. I'm struggling to organize a row of overflow images within the "small-img-row" division. This row is located under the main image in col-2. H ...

Bootstrap overrides the color of the calendar year in jQuery UI

I am facing an issue where the CSS styles of my jQuery UI calendar are being overridden by the Bootstrap CSS styles. Take a look at the screenshot provided. As you can see, the text color of the calendar's year is not black as intended. https://i.ss ...

display a dialogue box when clicked, containing radio buttons

I am currently developing a practice exam for students at my school. The exam consists of multiple choice questions, and I have hit a roadblock in the coding process. Being new to javascript, I am struggling to figure out how to make it function properly. ...

The ability to use the backspace and Ctrl + c (Copy) functions is restricted in input fields on FireFox

I have a form with input fields designed using semantic UI. I need the input field to only accept numbers, remove spaces, and allow copying from it using ctrl +c. After some investigation, I found this jQuery code that seems to satisfy my requirements per ...

Unable to modify the background image of a div using jQuery

I'm encountering an issue in my script where I tried to implement an event that changes the background-image of a div when a button is clicked, but it's not functioning as intended. Below is the code snippet: HTML <div class="col-md-2 image ...

Guide on Generating Dynamic Div Elements for Counted Value in PHP

I am receiving a dynamic div based on a count in a separate box, but I would like to have 6 fixed small divs inside the container. If the count value is 10, the additional divs should be automatically added according to the dynamic value. Below is my code ...

Is there a way to modify the border shape of items in the navigation bar?

Is there a way to achieve this particular shape when the current page is being displayed? https://i.stack.imgur.com/HELTM.jpg This is how my current code looks: current { transform: skew(-20deg); border: 1px solid white; color: black; background ...

Creating an HTML layout or template directly within a JavaScript bookmarklet

Currently, I am using a bookmarklet that generates a user interface for interaction. The method I have been using involves creating elements using $('<element>').addClass().css({..});, but this approach is proving to be difficult to maintai ...