First, it might be the issue that you are adding margin and paddings, which add size to the box even though the box has a width of 420px, you have to calculate margins and paddings to, or use * { box-sizing: border-box; }
, which will calculate the width of that element as a sum of all the sizes (padding, margin, width) and not exceed the width.
Second, the order of the elements are important when floating, put main always on top of the sidebar, since elements start as top to bottom, when you float a top element, the bottom element if its wider, will collapse and align with the main box.
Screenshot for reference:
![](https://readforlearn.com/wp-content/uploads/2022/01/uDcIs-1024x681.png)
Related Posts:
- Making a
- multiple classes on single element html
- How to insert spaces/tabs in text using HTML/CSS
- How to get these two divs side-by-side?
- Make div scrollable
- How to make the HTML link activated by clicking on the
- ?
- How to change text transparency in HTML/CSS?
- right align an image using CSS HTML
- How to completely remove borders from HTML table
- How do I right align div elements?
- Why “Inline-block” doesn’t work properly in this CSS?
- How to fix a footer overlapping content?
- How would you make two s overlap?
- What’s the HTML to have a horizontal space between two objects?
- height style property doesn’t work in div elements
- CSS “margin: 0 auto” not centering
- how to center an inline div using css?
- How can I insert vertical blank space into an html document?
- How to have an anim gif on a link and play it on hover and reset
- Align
elements side by side- Align text to the bottom of a div
- How to make a
- display in a horizontal row
- CSS – display: none; not working
- Failed to decode downloaded font
- Delete white space between divs
- Center HTML Input Text Field Placeholder
- creating a chevron in CSS
- Display Images Inline via CSS
- CSS/HTML: Create a glowing border around an Input Field
- Why CSS3 Animation is not working?
- Need to make a clickable
button- Set line height in Html
to make the html looks like a office word when
has different font sizes
- How to make fixed header table inside scrollable div?
- Removing whitespace between HTML elements when using line breaks
- CSS fixed width in a span
- How to get multiple images to auto resize and stay centered within a div
- Why are my divs overlapping?
- How can I center
- into a div?
- How to align this span to the right of the div?
- WordPress Admin Bar Overlapping Twitter Bootstrap Navigation [closed]
- How to Add Admin Bar and Admin Menu or Submenu Notification Bubbles?
- Why is WordPress changing my HTML code
- WordPress stripping out BR tags, need assistance
- How to insert html/css/javascript code to wordpress plugin
- How can i add note, caution, warning quote inside the text? [closed]
- how to setup content on a static frontpage with css and xhtml
- How to integrate my HTML and javascript into my child theme
- Get a blank line after div by simply leaving an empty line in the editor
- Can’t Display Table Headers in Responsive table layout
- What makes WP so SEO friendly?
- Title has word broken when viewed in mobile [closed]
- wordpress css file
- how to hide submenus for the not active pages
- How can I get the search form to be selected automatically?
- CSS – Initial HTML Margin Issue On WordPress Site
- Cannot set property ‘className’ of null at setThemeFromCookie
- Is it safe to use WordPress generated classes?
- HTML email sent with wp_mail shows plain text
- custom header navigation has odd spacing [closed]
- How to change the settings of a video? [closed]
- Acessing HTML element with no specific tag on it [closed]
- Responsive issue with secondary logo – not sticking in position [closed]
- Earlier stylesheet not overriding later one
- How to avoid repeating similar properties for all tds of a table in a wordpress post
- With over a page of content the footer remains where the bottom of the screen was at top scroll
- I have html form and need to make it work in text editor on template. Only problem is it has .sccs styling file
- Where to add this code for a Modal box to work? [closed]
- WordPress login using a completely custom page and no plugins?
- How to display image on WordPress homepage
- Unable to use Datepicker in a table when inserting a row
- Img load while refreshing
- Navigation menu disappears when I hover the mouse [closed]
- how to modify html on homepage (no home-page.php in my theme)
- current menu item hover not working?
- Content going full width even though container is not
- How to Compress Css/js code in wordpress and increase loading speed?
- Bootstrap News: Image Modifciation
- Page flickers when new html5 video loads
- Divi Theme HTML code is different in View Page Source than in the Firefox Inspector
- How to Take Logo Out of Navigation Menu? [closed]
- @media applying globally and not separately for each screen width [closed]
- Css style removed but still showing via CDN even after clearing browser cache and purging all caches for site
- My contact form is not being responsive
- I cannot make this position properly in WordPress [closed]
- Import HTML code that loads css and javascript into specific page
- checkbox function not working for dropdown menu
- Pages in another language
- Add HTML input tag to to site navigation
- Outputting the blogposts or the_content()
- Converting Static HTML pages to WordPress
- Interactive maps in wordpress
- I need css code to divide my webpage sections into two columns
- How to add input search field with roudned corners?
- Rollover button doesn’t appear in sidebar [closed]
- How can I use Advanced Custom Field Option page in CSS WordPress
- WordPress site suddenly not showing some DOM elements but mobile is fine
- Grid problem on privew mode
- Editing size of h3 tag in wordpress on a one-off basis
- IOS Ventura Safari 16.3 position fixed elements goes above scroll bar
- Elementor Contact Form Submit button has empty class