Depiction of the CSS Box Model in CSS1The four margin properties for each side of the box and the margin shorthand were all defined in CSS1.The CSS2.1 specification has an illustration to demonstrate the Box Model and also defines terms we still use to describe the various boxes. The specification describes the content box, padding box, border box, and margin box, each being defined by the edges of the content, padding, border, and margin respectively. Posted on 15th July 2019Web Design FacebookshareTwittertweetGoogle+share Everything You Need To Know About CSS Margins Everything You Need To Know About CSS Margins Rachel Andrew 2019-07-15T12:30:59+02:00 2019-07-15T12:36:09+00:00One of the first things most of us learned when we learned CSS, was details of the various parts of a box in CSS, described as The CSS Box Model. One of the elements in the Box Model is the margin, a transparent area around a box, which will push other elements away from the box contents. The margin-top, margin-right, margin-bottom and margin-left properties were described right back in CSS1, along with the shorthand margin for setting all four properties at once.A margin seems to be a fairly uncomplicated thing, however, in this article, we will take a look at some of the things which trip people up with regard to using margins. In particular, we will be looking at how margins interact with each other, and how margin collapsing actually works.The CSS Box ModelAs with all articles about parts of the CSS Box Model, we should define what we mean by that, and how the model has been clarified through versions of CSS. The Box Model refers to how the various parts of a box — the content, padding, border, and margin — are laid out and interact with each other. In CSS1, the Box Model was detailed with the ASCII art diagram shown in the image below. DepvTools can help you see where your margin ends upOnly Block Margins CollapseThe last example also highlights something about margin collapsing. In CSS2, only vertical margins are specified to collapse — that is the top and bottom margins on an element if you are in a horizontal writing mode. So the left and right margins above are not collapsing and ending up outside the wrapper.Note: It is worth remembering that margins only collapse in the block direction, such as between paragraphs.Things Which Prevent Margin CollapsingMargins never collapse if an item has absolute positioning, or is floated. However, assuming you have run into one of the places where margins collapse outlined above, how can you stop those margins collapsing?The first thing that stops collapsing is situations where there is something between the elements in question.For example, a box completely empty of content will not collapse it’s top and bottom margin if it has a border, or padding applied. In the example below I have added 1px of padding to the box. There is now a 50-pixel margin above and below the box.See the Pen [Margins: empty boxes with padding do not collapse](https://codepen.io/rachelandrew/pen/gNeMpg) by Rachel Andrew. See the Pen Margins: empty boxes with padding do not collapse by Rachel Andrew.This has logic behind it, if the box is completely empty with no border or padding, it is essentially invisible. It might be an empty paragraph element thrown into the markup by your CMS. If your CMS was adding redundant paragraph elements, you probably wouldn’t want them to cause large gaps between the other paragraphs due to their margins being honored. Add anything to the box, and you will get those gaps.Similar behavior can be seen with margins on first or last children which collapse through the parent. If we add a border to the parent, the margins on the children stay inside.See the Pen [Margins: margin on first and last child doesn’t collapse if the parent has a border](https://codepen.io/rachelandrew/pen/vqRKKX) by Rachel Andrew. See the Pen Margins: margin on first and last child doesn’t collapse if the parent has a border by Rachel Andrew.Once again, there is some logic to the behavior. If you have wrapping elements for semantic purposes that do not display visually, you probably don’t want them to introduce big gaps in the display. This made a lot of sense when the web was mostly text. It is less useful as behavior when we are using elements to lay out a design.Creating a Block Formatting ContextA new Block Formatting Context (BFC) will also prevent margin collapsing through the containing element. If we look again at the example of the first and last child, ending up with their margins outside of the wrapper, and give the wrapper display: flow-root, thus creating a new BFC, the margins stay inside.See the Pen [Margins: a new Block Formatting Context contains margins](https://codepen.io/rachelandrew/pen/VJXjEp) by Rachel Andrew. See the Pen Margins: a new Block Formatting Context contains margins by Rachel Andrew.To find out more about display: flow-root, read my article “Understanding CSS Layout And The Block Formatting Context”. Changing the value of the overflow property to auto will have the same effect, as this also creates a new BFC, although it may also create scrollbars that you didn’t want in some scenarios.Flex And Grid ContainersFlex and Grid containers establish Flex and Grid formatting contexts for their children, so they have different behavior to block layout. One of those differences is that margins do not collapse:“A flex container establishes a new flex formatting context for its contents. This is the same as establishing a block formatting context, except that flex layout is used instead of block layout. For example, floats do not intrude into the flex container, and the flex container’s margins do not collapse with the margins of its contents.”— Flexbox Level 1If we take the example above and make the wrapper into a flex container, displaying the items with flex=direction: column, you can see that the margins are now contained by the wrapper. Additionally, margins between adjacent flex items do not collapse with each other, so we end up with 100 pixels between flex items, the total of the 50 pixels on the top and bottom of the items.See the Pen [Margins: margins on flex items do not collapse](https://codepen.io/rachelandrew/pen/mZxreL) by Rachel Andrew. See the Pen Margins: margins on flex items do not collapse by Rachel Andrew.Margin Strategies For Your SiteDue to margin collapsing, it is a good idea to come up with a consistent way of dealing with margins in your site. The simplest thing to do is to only define margins on the top or bottom of elements. In that way, you should not run into margin collapsing issues too often as the side with a margin will always be adjacent to a side without a margin.Note: Harry Roberts has an excellent post detailing the reasons why setting margins only in one direction is a good idea, and not just due to solving collapsing margin issues.This solution doesn’t solve the issues you might run into with margins on children collapsing through their parent. That particular issue tends to be less common, and knowing why it is happening can help you come up with a solution. An ideal solution to that is to give components which require it display: flow-root, as a fallback for older browsers you could use overflow to create a BFC, turn the parent into a flex container, or even introduce a single pixel of padding. Don’t forget that you can use feature queries to detect support for display: flow-root so only old browsers get a less optimal fix.Most of the time, I find that knowing why margins collapse (or didn’t) is the key thing. You can then figure out on a case-by-case basis how to deal with it. Whatever you choose, make sure to share that information with your team. Quite often margin collapsing is a bit mysterious, so the reason for doing things to counter it may be non-obvious! A comment in your code goes a long way to help — you could even link to this article and help to share the margin collapsing knowledge.I thought that I would round up this article with a few other margin-related pieces of information.Percentage MarginsWhen you use a percentage in CSS, it has to be a percentage of something. Margins (and padding) set using percentages will always be a percentage of the inline size (width in a horizontal writing mode) of the parent. This means that you will have equal-sized padding all the way around the element when using percentages.In the CodePen example below, I have a wrapper which is 200 pixels wide, inside is a box which has a 10% margin, the margin is 20 pixels on all sides, that being 10% of 200.See the Pen [Margins: percentage margins](https://codepen.io/rachelandrew/pen/orqzrP) by Rachel Andrew. See the Pen Margins: percentage margins by Rachel Andrew.Margins In A Flow-Relative WorldWe have been talking about vertical margins throughout this article, however, modern CSS tends to think about things in a flow relative rather than a physical way. Therefore, when we talk about vertical margins, we really are talking about margins in the block dimension. Those margins will be top and bottom if we are in a horizontal writing mode, but would be right and left in a vertical writing mode written left to right.Once working with logical, flow relative directions it becomes easier to talk about block start and block end, rather than top and bottom. To make this easier, CSS has introduced the Logical Properties and Values specification. This maps flow relative properties onto the physical ones.For margins, this gives us the following mappings (if we are working in English or any other horizontal writing mode with a left-to-right text direction).margin-top = margin-block-startmargin-right = margin-inline-endmargin-bottom = margin-block-endmargin-left = margin-inline-startWe also have two new shorthands which allow for the setting of both blocks at once or both inline.margin-blockmargin-inlineIn the next CodePen example, I have used these flow relative keywords and then changed the writing mode of the box, you can see how the margins follow the text direction rather than being tied to physical top, right, bottom, and left.See the Pen [Margins: flow relative margins](https://codepen.io/rachelandrew/pen/BgrQRj) by Rachel Andrew. See the Pen Margins: flow relative margins by Rachel Andrew.You can read more about logical properties and values on MDN or in my article “Understanding Logical Properties And Values” here on Smashing Magazine.To Wrap-UpYou now know most of what there is to know about margins! In short:Margin collapsing is a thing. Understanding why it happens and when it doesn’t will help you solve any problems it may cause.Setting margins in one direction only solves many margin related headaches.As with anything in CSS, share with your team the decisions you make, and comment your code.Thinking about block and inline dimensions rather than the physical top, right, bottom and left will help you as the web moves towards being writing mode agnostic. (il)From our sponsors: Everything You Need To Know About CSS Margins HomeWeb DesignEverything You Need To Know About CSS Margins Depection of the CSS Box Model in CSS2There is now a Level 3 Box Model specification as a Working Draft. This specification refers back to CSS2 for the definitions of the Box Model and margins, therefore it is the CSS2 definition we will be using for the majority of this article.Margin CollapsingThe CSS1 specification, as it defined margins, also defined that vertical margins collapse. This collapsing behavior has been the source of margin-related frustration ever since. Margin collapsing makes sense if you consider that in those early days, CSS was being used as a documenting formatting language. Margin collapsing means that when a heading with a bottom margin, is followed by a paragraph with a top margin, you do not get a huge gap between those items.When margins collapse, they will combine so that the space between the two elements becomes the larger of the two margins. The smaller margin essentially ending up inside the larger one.Margins collapse in the following situations:Adjacent siblingsCompletely empty boxesParent and first or last child elementLet’s take a look at each of these scenarios in turn, before looking at the things which prevent margins from collapsing in these scenarios.Adjacent SiblingsMy initial description of margin collapsing is a demonstration of how the margins between adjacent siblings collapse. Other than in the situations mentioned below, if you have two elements displaying one after the other in normal flow, the bottom margin of the first element will collapse with the top margin of the following element.In the CodePen example below, there are three div elements. The first has a top and bottom margin of 50 pixels. The second has a top and bottom margin of 20px. The third has a top and bottom margin of 3em. The margin between the first two elements is 50 pixels, as the smaller top margin is combined with the larger bottom margin. The margin between the second two elements in 3em, as 3em is larger than the 20 pixels on the bottom of the second element.See the Pen [Margins: adjacent siblings](https://codepen.io/rachelandrew/pen/OevMPo) by Rachel Andrew. See the Pen Margins: adjacent siblings by Rachel Andrew.Completely Empty BoxesIf a box is empty, then it’s top and bottom margin may collapse with each other. In the following CodePen example, the element with a class of empty has a top and bottom margin of 50 pixels, however, the space between the first and third items is not 100 pixels, but 50. This is due to the two margins collapsing. Adding anything to that box (even padding) will cause the top and bottom margins to be used and not collapse.See the Pen [Margins: empty boxes](https://codepen.io/rachelandrew/pen/JQLGMr) by Rachel Andrew. See the Pen Margins: empty boxes by Rachel Andrew.Parent And First Or Last Child ElementThis is the margin collapsing scenario which catches people out most often, as it does not seem particularly intuitive. In the following CodePen, I have a div with a class of wrapper, and I have given that div an outline in red so that you can see where it is. The three child elements all have a margin of 50 pixels. However, the first and last items are flush with the edges of the wrapper; there is not a 50-pixel margin between the element and the wrapper.See the Pen [Margins: margin on first and last child](https://codepen.io/rachelandrew/pen/BgrKGp) by Rachel Andrew. See the Pen Margins: margin on first and last child by Rachel Andrew.This is because the margin on the child collapses with any margin on the parent thus ending up on the outside of the parent. You can see this if you inspect the first child using DevTools. The highlighted yellow area is the margin. Everything You Need To Know About CSS MarginsYou are here: Related postsInclusive Components: Book Reviews And Accessibility Resources13th December 2019Should Your Portfolio Site Be A PWA?12th December 2019Building A CSS Layout: Live Stream With Rachel Andrew10th December 2019Struggling To Get A Handle On Traffic Surges10th December 2019How To Design Profitable Sales Funnels On Mobile6th December 2019How To Build A Real-Time Multiplayer Virtual Reality Game (Part 2)5th December 2019
I have been asked lately about which Ultrabooks support Intel® vPro™ Technology? Below is a list* of some of the latest of the Intel vPro enabled Ultrabooks available today:*Note: This list above is not all of the Intel vPro capable Ultrabooks available, just a few to get you started! Feel free to share your favorite Intel vPro enabled Ultrabook by replying to this post! To see even more, visit Ultrabook™ for Business
Japan’s previous best effort in terms of gold medals was as host of the 1964 Tokyo Olympics and at the 2004 Athens Games, when they won 16.Thirty golds would have put them above second-placed Britain’s 27 in Rio, but still a long way behind the table-topping United States, who captured 46.Yamashita was also bullish about Japan’s chances at next year’s Winter Olympics in Pyeongchang, South Korea, predicting nine medals overall.The country’s previous best haul at a Winter Games was five gold medals and 10 in total as host of the Nagano Olympics in 1998.ADVERTISEMENT Winter storm threatens to scramble Thanksgiving travel plans Ethel Booba on hotel’s clarification that ‘kikiam’ is ‘chicken sausage’: ‘Kung di pa pansinin, baka isipin nila ok lang’ Sports Related Videospowered by AdSparcRead Next MVP favorite Fajardo, Beermen likely to banner Mythical Team LATEST STORIES MOST READ Don’t miss out on the latest news and information. “I reckon we can aim to get 2.5 times the amount we did in Rio,” the former Olympic judo champion told local media, pointing to Japan’s recent success in gymnastics, table tennis and badminton.“That’s just my personal opinion, not that of the technical committee,” added the 60-year-old Yamashita, who was Japan’s deputy chef de mission in Brazil.FEATURED STORIESSPORTSSEA Games: Biñan football stadium stands out in preparedness, completionSPORTSPrivate companies step in to help SEA Games hostingSPORTSBoxers Pacquiao, Petecio torchbearers for SEA Games opening“We will collect the relevant data and decide (the official target) hopefully by next summer.”Yamashita, who won judo gold at the 1984 Los Angeles Olympics, also raised the hope that the host nation’s track athletes could deliver a surprise after a Japanese sprinter, Yoshihide Kiryu, finally broke the 10-second barrier last month after years of trying. ‘A complete lie:’ Drilon refutes ‘blabbermouth’ Salo’s claims No more menthol cigarettes: New ban on tobacco, vape flavors Jordan delivers on promise: 2 Cobra choppers now in PH Robredo: True leaders perform well despite having ‘uninspiring’ boss PLAY LIST 02:49Robredo: True leaders perform well despite having ‘uninspiring’ boss02:42PH underwater hockey team aims to make waves in SEA Games01:44Philippines marks anniversary of massacre with calls for justice01:19Fire erupts in Barangay Tatalon in Quezon City01:07Trump talks impeachment while meeting NCAA athletes02:49World-class track facilities installed at NCC for SEA Games Trump to designate Mexican drug cartels as terrorist groups Hotel says PH coach apologized for ‘kikiam for breakfast’ claim Argentine bishop appears at court hearing on abuse charges 2020 summer Olympic games host city, Tokyo, is projected on the floor as dancers perform during the closing ceremony in the Maracana stadium at the 2016 Summer Olympics in Rio de Janeiro, Brazil, Sunday, Aug. 21, 2016. (AP Photo/Natacha Pisarenko)A senior Japanese Olympic official has called on the host country’s athletes to win a national-record 30 gold medals at the 2020 Summer Games, local media reported Friday.Japanese Olympic Committee (JOC) sports committee chairman Yasuhiro Yamashita backed home-grown competitors to more than double their haul of 12 golds at last year’s Rio Olympics, where Japan finished sixth in the medal table.ADVERTISEMENT View comments
Episode #44 – June 12th, 2009 (Episode Length: 32 minutes, 36 second) Blog article: http://itunes.hubspot.tv to learn how to create a thriving blog. @ Names based on your page or personal name, no “generic” words allowed ) : Get your darn Facebook URL tonight at midnight! Closing Coming Soon: Facebook Usernames Inbound Marketing University ! (Starts next Monday.) FAQ: Learn how to build your business blog into an inbound marketing machine. Facebook Goes In-Vain DJ on the side! Eons.com Marketing Takeaway Originally published Jun 13, 2009 9:15:00 AM, updated July 04 2013 Remember to subscribe in iTunes: Headlines Marketing Takeaway Doing It Right Blog article: Many Twitter “accounts” are actually not that active: Inboundmarketing.com Announcing the June 2009 State of the Twittersphere Report Twitter Scavenger Hunt Meets Gossip Girl How to interact on Twitter: @ : New site where you can post questions, learn about inbound marketing, meet others, find and post jobs or sign up for World’s Largest Twitter Study by HubSpot Reports Over Half of Accounts Don’t Tweet Vacant Homes in Twitterville Contextweb Facebook (finally!) allows simple “vanity” URLs for profiles and pages (not groups) Download the free webinar Now at News release: asks, “How do you measure the effectiveness of public speaking engagements? How do you measure an ROI?” , a social network for baby boomers Facebook Usernames Coming Soon for Pages Announcement: Authenticity vs. Authority 55% of accounts are not following anyone Marketing Tip of the Week Battle of the Search Engine Marketing Fox Fever Forum Fodder : Publish interesting data in order to get PR. : Authenticity with gain you authority, which is what you need to worry about as a marketer. www.inboundmarketing.com/forum : Today’s big brands are being built with inbound marketing. The “buzz” has driven a lot of tire kickers to Twitter, more than passionate users. Google & Firefox have gone inbound with user generated content and creating a buzz: Intro mvolpe Bing is going outbound with the marketing blitz Special Guest: Jeff Taylor, Monster.com & Eons.com Mailbag Founder, CEO and Chief Monster of 55% of users have never tweeted Authenticity vs. Authority Nobody Recognizes The Chrome Icon, So Google Wants You To Make A Video About It (To ask a question that you’d like to appear in Forum Fodder, visit Lots of coverage in GigaOm, SF Chronicle, VentureBeat, NECN, Seattle Post Intelligencer, Monster.com Aquick question; if I embed a video from youtube on our website; do thewebsite video views get counted towards the youtube page total views? Marketing Takeaway 53% of users have no followers : Tonight at midnight, get your Facebook vanity URL! No cheating – business page must be from before May 31 and have 1,000+ fans Marketing Takeaway Webinar: Advanced Business Blogging Ken Lauher of karenrubin HubSpot released our second report on Twitter – “State of the Twittersphere – June 2009” SethGodin: “If it’s a word game, then authority wins, because authority isabout the perception of the consumer. If they believe you an authority,you are. In the long run, of course, authenticity will trump it,because your authority fades without it. The converse is not true. Andyes, it’s a word game.” Don’t forget to share this post! AddThis Sharing ButtonsShare to TwitterTwitterShare to FacebookFacebookShare to Email AppEmail AppShare to LinkedInLinkedInShare to MessengerMessengerShare to SlackSlack
presentations Fortunately, the web has helped solve this problem by making it easier to share and watch social media marketing presentations Have you seen other presentations that should be on this list? Please share links to them in the comments of this post! presentations from Social Media Strategy from 8 Digital Trends That Will Change Everything by Christina “CK”Kerley Branding Personality View more Do’s and dont’s of Social Media by from 4. The 25 Basic Styles of Blogging … And When To Use Each One View more . Olivier Blanchard Basics Of Social Media Roi 7 Ways to Use Social Media to Build Stunning Business and Personal Brands by B2B Social Media Marketing by presentations 8. Olivier Blanchard View more . Presentations are a great way to consume information and learn about new topics. Unfortunately, we don’t all have the time and money to spend traveling to conferences to see them in person. View more has become a powerful resource for discovering new ideas. Today, we selected some of the best View more presentations from 11. Adam Singer 2.Basics Of Social Media Roi by Employees are Social Media Marketers, Too! (they just don’t know it yet) by Jay Baer 7. Rohit Bhargava that are worth watching and could inspire slides for your own presentations. . . presentations ducttape presentations presentations Topics: ducttape presentations Josh Martin B2B Social Media Marketing: Building the B2B Business Case for Social Media presentations Conversation by Design Christina “CK” Kerley Rohit Bhargava presentations Slideshare David Armano 6. . Originally published Apr 27, 2010 8:00:00 AM, updated October 20 2016 What the F**K is Social Media: One Year Later by View more 7 Ways to Use Social Media to Build Stunning Business and Personal Brands . . Joffreys Coffee & Tea Company Social Media Marketing Case Study by JayBaer from View more DavidArmano . MartaKagan . Employees are Social Media Marketers, Too! (they just don’t know it yet) from View more from 9. Gia Lyons Social Media Marketing Presentations Do’s and dont ‘s of Social Media 3. Conversation by Design by Branding Personality from presentations 10. View more Adam Singer 1.The 25 Basic Styles of Blogging … And When To Use Each One by from from . 5. Marta Kagan from Olivier Blanchard presentations Joffreys Coffee & Tea Company Social Media Marketing Case Study 8 Digital Trends That Will Change Everything – March 2010 Social Media Strategy by Social Media Marketing What the F**K is Social Media: One Year Later . . Josh Martin View more View more Gia Lyons Don’t forget to share this post! AddThis Sharing ButtonsShare to TwitterTwitterShare to FacebookFacebookShare to Email AppEmail AppShare to LinkedInLinkedInShare to MessengerMessengerShare to SlackSlack
20 percent of Google searches are for local information Mayer discussed many of Google’s local applications, including Google Maps and Google Hotpot Originally published Mar 17, 2011 4:00:00 PM, updated October 20 2016 Marissa Mayer Google Hotpot currently has 3 million ratings 5 Google Local Stats Every Marketer Should Know Local SEO Google Maps usage is 40 percent mobile 2. aburt 3. Google GPS saves drivers 2 years everyday with route around traffic directions 4. , Google’s Vice President of Consumer Products, spoke about the current state of many of Google’s location-focused applications. Five important statistics stood out as the major takeaways for marketers looking to promote their businesses at the local level. 5. Topics: Google Maps has 150 million mobile users When it comes to location-based marketing, much of the conversation goes to Foursquare as well as Yelp. However, Google is still the leader in the discovery process for local information. At South By South West Interactive, Of the five stats above, it is clear that the fifth piece of data should serve as a soundbite for every marketer when discussing the relevancy of online local marketing. With 20 percent of Google searches looking for local information, that means 600 million searches per day are for local information. This is a huge opportunity for businesses. Don’t forget to share this post! AddThis Sharing ButtonsShare to TwitterTwitterShare to FacebookFacebookShare to Email AppEmail AppShare to LinkedInLinkedInShare to MessengerMessengerShare to SlackSlack All of these statistics show that Google has a major hold on users looking for local marketing online. As a business looking to attract more customers through these tools, you should follow best practices for being included in Google’s local search results as well as optimize your business website with content focused on your key geographic markets. Take a look at 1. Photo Credit: . Hotpot is Google’s service that allows users to rate local business and has only been live for a few months now. Marketing Takeaway HubSpot’s free local marketing on-demand webinar for best practices to attract more visitors to your business.
Recently, I posted an If you’re an inbound marketer, chances are you have lots of data to analyze and you base your most important decisions on quantitative measures. In this blog series, I discuss some the most useful tools and tricks for analyzing your data in Excel. Suppose your pivot table is calculating the average click through rate of your email sends and you want to rank the results from lowest to highest click through rate. . If you’ve already mastered creating pivot tables, here are a few advanced features… once you start using these, you’ll wonder how you ever survived without them! 1. Sort alphabetically or numerically. Originally published Apr 19, 2011 12:30:00 PM, updated October 20 2016 2. Group columns and rows. article about the magic of pivot tables You can actually use the Grouping feature for any label type, not just dates. Just highlight the rows you want to put into one group and select the “Group” option. Once your group has been created, you can then type over the default group name to label the group however you’d like. For example, if I wanted to hide all of the rows with a click through rate under 30%, I would select “Value Filters” from the popup menu. What other tips would you add to this list? 4. Filter values, columns, or rows. In the example at right, I’m dragging and droping the “Event Invitation” row up above “Breaking News”. Don’t forget to share this post! AddThis Sharing ButtonsShare to TwitterTwitterShare to FacebookFacebookShare to Email AppEmail AppShare to LinkedInLinkedInShare to MessengerMessengerShare to SlackSlack Excel Suppose you have a pivot table with a long list of dates that you want to group by month. You can do this in a snap with the Grouping feature. In this screenshot, I right-clicked on a random “Email date” and selected “Group” from the popup menu. To do this, select the row you want to move and hover over the edge until you see the crosshairs with arrows. Then simply drag and drop it higher or lower in the table. Topics: 3. “Drag & Drop” rows and columns. Don’t like the order of your rows? This happens to me a lot. A simple and quick fix is to simply drag and drop the row.