Make desktop view the default even when accessing from a mobile device

I have searched through all other similar questions but have not been able to find a solution. I am new to programming and am currently learning CSS. I have created a webpage with the following code:

<html>
<style>
    body {
    p.Welcome {
      font-family: "Comic Sans MS", cursive, sans-serif;
      font-size: 23px;
      font-weight: bold;
      color: white;
      text-align: center;
    }
    section {
      border-radius: 1em;
      padding: 1em;
      position: absolute;
      top: 49%;
      left: 50%;
      margin-right: -50%;
      transform: translate(-50%, -50%)
    }
</style>
<section>
  <p class="Welcome">hi</p>
  <img src="blablabla whatever image" />
</section>


<html/>

My goal is to display the desktop version of the page even on mobile devices. I want the same page to be shown without any changes in resolution or layout when accessed from a mobile device.

Answer №1

I have provided some comments below to assist you in correcting errors in your HTML code. It is important to note that these errors can lead to discrepancies in how different browsers interpret the code due to varying engines and methods.

Additional Comments:

  • Avoid using empty rule declarations (found under the body rule in CSS).
  • Always remember to include closing tags. Consider using Sublime, VS Code, or Atom as they provide "problem" notifiers to help catch mistakes while learning (found under the body rule in CSS).
  • If aiming for responsiveness, try to avoid absolute positioning to prevent the need for excessive media querying for consistent results (found under section rule in CSS).
  • Ensure all opened tags are closed, especially for compatibility across browsers. Leaving it to the browser to interpret may result in different displays (located above the closing body tag in HTML).
  • When closing HTML tags, use the format </html>. Slashes after indicate self-closing tags (at the end of the document).

To directly address your query, designing for responsiveness can be challenging. Screens vary in sizes and dimensions, requiring adaptable design. If an element is set to a fixed width but the screen size is smaller, it will not display correctly.

In conclusion, there is no way to avoid considering responsiveness in design. While it may require effort, developing good habits over time is essential. I recommend exploring freeCodeCamp for valuable challenges and resources to improve responsiveness and fundamental skills like the box model.

<!-- Always specify your DOCTYPE, noting its case sensitivity -->
<!DOCTYPE html>
<html>
<!-- Remember to include a head tag -->
<head></head>
<style type="text/css">
  /* Avoid using empty rule declarations */ body {}
  /* Check for closing tags. Consider tools like Sublime, VS Code, or Atom with error notifications for easier debugging. */

  p.Welcome {
    font-family: "Comic Sans MS", cursive, sans-serif;
    font-size: 23px;
    font-weight: bold;
    color: white;
    text-align: center;
  }

  section {
    border-radius: 1em;
    padding: 1em;
    position: absolute;
    /* For better responsiveness, minimize absolute positioning to reduce reliance on media queries */
    top: 49%;
    left: 50%;
    margin-right: -50%;
    transform: translate(-50%, -50%)
  }
</style>
<!-- Use sections to enhance semantic clarity by summarizing content -->
<section id="welcome">
  <p class="Welcome">hi</p>
  <img src="http://whatever.com/image.jpg" />
</section>
<!-- Ensure all tags are properly closed for consistency among browsers -->
</body>
<!-- Close HTML tags with the format </html>. Use slashes for self-closing tags -->

</html>

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 positioning of the second wrapper in absolute does not match the behavior of the first wrapper

Working with CSS can be tricky, especially when dealing with nested navigation elements. I am facing an issue where the styles that work perfectly for one dropdown menu do not function as expected for subsequent nested navigations. My objective is to disp ...

Clone the children of an li element using jQuery, modify the text within a child tag, and then add it to

I have some awesome CSS that I want to recycle within a <ul>. My plan is to duplicate an existing <li> (to leverage the CSS), modify a <p> element, and then add it at the end of the <ul>. I believe I can achieve this by locating... ...

Customize Your Lists in Wordpress to Reflect Your Unique Style

I need help with styling a specific text widget in Wordpress by adding a FontAwesome icon as a list bullet. I have the following CSS code: .covenant li { counter-increment: my-awesome-counter; margin: 0.25rem; } .covenant li:before { font-family: 'Fo ...

Enhanced spacing of characters in website text

Currently working on a client's website, I find myself once again being asked by my boss (who is the designer) to increase letter-spacing in the text for aesthetic reasons. However, I strongly believe that this practice can actually lead to eye strain ...

Using form.submit() alongside preventDefault() will not yield the desired outcome

My login form needs to either close the lightbox or update the error box based on the success of the login attempt. I suspect the issue lies with the onclick="formhash(this.form, this.form.password);" which is a JavaScript function that hashes a passwor ...

The button is not being vertically centered when using the boostrap pull-right class

---------------------------------------------------------------- | Title | | Button | --> (using .pull-right) the button is not aligned vertically ------------------------------------------------------------- ...

The Bootstrap DateTimePicker is displaying on the screen in an inaccurate

I'm having an issue with the datetimepicker on my project. The calendar appears incorrectly in Chrome, but looks fine in Edge. Here's a screenshot from Chrome: https://i.stack.imgur.com/Hi0j4.png And here is how it looks in Edge: https://i.stac ...

When resizing, headers within Bootstrap text fail to adjust accordingly

I have created a card-like component in my HTML with text inside. My issue is that when I resize the page, the card shrinks but the text overflows. Currently, I am using Bootstrap 5 and its h4 class like this: <div class="card bg-white"> ...

The validation process is still failing even though the correct credentials have been entered

I'm diving into the world of Javascript and DOM today, but I've hit a roadblock. Can you take a look at this code snippet and help me figure out what's causing me to always end up in the else block, no matter what I input in the text field? ...

Struggling with the transition of a CSS navigation menu from hover to focus

I'm attempting to transition a "mega menu" from 'hover' to 'focus'. My goal is to have the dropdown menus appear "on click" and remain visible until another top-level selection is clicked. Ideally, I am looking for a CSS-only solut ...

When I expand one panel, I want to automatically close any other opened panel to ensure only one section is expanded at a

I'm experiencing an issue with the Bootstrap 4 accordion. Currently, when I open a collapsed section in the accordion, it remains open even when I click on another collapsed section. What I actually want is for the previously opened section to close ...

Is it possible to create an HTML select that displays transparent text after a selection

I'm currently working on customizing the appearance of an HTML select element with various background color options. Everything is functioning properly, but I have a specific requirement. I want the text in the dropdown options to be visible only when ...

AngularJS mdDialog not supporting Tinymce functionality

I'm attempting to integrate the TinyMCE editor into an AngularJS mdDialog. Working Plunker: http://embed.plnkr.co/s3NsemdcDAtG7AoQRvLh/ Plunker with issues: http://embed.plnkr.co/fL8kGLl3b4TNdxW1AtKG/ All features are working fine except for the d ...

Using HTML and CSS to create a flexbox layout with multiple rows

.ent__food__image { display: flex; justify-content: end; } .bev__food__image { display: flex; justify-content: end; } .kids__food__image { display: flex; justify-content: end; } <main class="flex-container"> <!-- Entrees --> & ...

Updating the Position of an Element in ElectronJS (e.g. Button, Label, etc)

Is there a way to change the positioning of a button in a window using JavaScript and Electron? I am trying to create new input boxes next to existing ones, but they always appear below the last one created. Is it possible to specify x and y coordinates fo ...

Changing position attributes on fixed divs may not function properly on Android devices

Utilizing CSS transitions, I've successfully managed to make divs move, but unfortunately, this functionality does not work on Android devices. When the div is set to position:fixed, it remains static without any movement. Here is the original code ...

When viewed on mobile browsers, the side-by-side divs in a tabbed layout appear to be

Looking for some help with responsive design for the "PORTFOLIO ATTRIBUTES" tab on my website. On desktop, the content displays fine, but on mobile it overlaps and cuts off. Here's the link to the page in question: . Any suggestions on how to maintai ...

Issues with table-cell rendering in Chrome

I have three different divisions that I would like to showcase as table cells: <div class="field"> <div class="row"> <label for="name">Subdomain</label> <input type="text" id="name" name="name"> &l ...

Overflow-y SweetAlert Icon

Struggling with a website modification issue where using Swal.fire(...) causes an overflow problem affecting the icon rendering. How can this be fixed? Here is the custom CSS code in question: * { margin: 0px; padding: 0px; font-family: &ap ...

Encountered SyntaxError: An unexpected token has been found while integrating leaflet with flask

Despite adding all necessary scripts and configuring my API_KEY in config.js, I keep getting an error message saying "Uncaught SyntaxError: Unexpected token." I have double-checked my API key multiple times, and it seems to be correct. Here is a snippet f ...