quick question about HTML5 article and figure element - html

I have a section where there is a image of a site and a paragraph thats referencing to that site. I am wondering what would be the correct way, in your opinion how I should wrap these 2 HTML objects.
I have originally thought this would just work(ignore .img-wrap and the h2):
<section class="featured">
<h1> Featured Project </h1>
<div class="img-wrap">
<img src="" height="" width="" alt="Name of Site">
<h2> Title </h2>
</div><!-- .img-wrap -->
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing
elit, seddo eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
</p>
</section><!-- .featured -->
But what if my client adds multiple paragraphs? It will be styled with a background color and margin so it wouldn't look right.
Wouldn't figure and figcaption be appropriate? I can't really tell when I read on it on HTML5Doctor.
<section class="featured">
<h1> Featured Project </h1>
<figure>
<div class="img-wrap">
<img src="" height="" width="" alt="Name of Site">
<h2> Title </h2>
</div><!-- .img-wrap -->
<figcaption>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing
elit, seddo eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
</p>
</figcaption>
</figure>
</section><!-- .featured -->
Or maybe just wrap the paragraph?

It's hard to say what the best practice here would be since you haven't given us enough context. I doubt that what you're showing us here really is a good candidate for a <section>, since it seems more like the bulk of an article, especially with that <h1> thrown in there.
As far as using that <figcaption> around paragraphs of content, well, that's not really what it's intended for. Think about a newspaper or magazine article with an image or two to spice it up. The image isn't described in the body of the content, but the image content is related to the article. The captions on the image are brief descriptions of what the image is showing, usually to clarify who or what you're looking at.
For your situation, something like the following might be most appropriate:
<article id="featured">
<h1>Featured Project</h1>
<figure>
<img src="image.jpg" alt="A brief caption about the image.">
<figcaption>A brief caption about the image.</figcaption>
</figure>
<p>
Lorem ipsum, your articlus can goeth here.
</p>
</article>
There's no need for you to wrap the entire article inside of a <figcaption> wrapped inside a <figure>, just to show an image. You don't have to use <figure> at all, and if you do, a <figcaption> is quite possibly unnecessary. Don't get caught up with trying to use HTML5 elements just for the sake of using them. If you don't think there's a compelling reason to use them, your time is probably better spent just getting things built and iterating over them later to make semantic improvements to the markup.

Related

Problem to add background using Skeleton Grid

I'm new on programing and I'm studying HTML and CSS.
But today I have a issue that I can't figure how to solve:
I'm trying to add a background to a footer and it work pretty nice. But when I add "columns class" in some 'divs' it jusp stop works.
I'm adding two JS, first one whitout columns' class and a seccond one whit columns' class.
I know I'm doing something wrong, but I can't figure what.
First Code whit background working perfectly
Seccond Code whit background does't work
And I'm puting here my HTML code:
<footer>
<div class="footer">
<div class="container">
<div class="six columns">
<h3>Nossa História</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="three columns">
<h3>Contato</h3>
<ul>
<li>- 38 99999-9999</li>
<li>- contato#bikcraft.com</li>
<li>- Salinas - MG</li>
</ul>
</div>
<div class="three columns">
<h3>Redes Sociais</h3>
<ul>
<li><img src="img/facebook-icone.svg" alt="Ícone Facebook"></li>
<li><img src="img/instagram-icone.svg" alt="Ícone Instagram"></li>
<li><img src="img/youtube-icone.svg" alt="Ícone Youtube"></li>
</ul>
</div>
</div>
</div>
</footer>
And my CSS code:
.footer {
color: #fefefd;
background: #191f28;
}

Could I use div and article inside section?

I have a section which is devided by 2 parts. Left side is only for image and right - only for article. Is my code correct?
<section>
<h1>Section header</h1>
<div style="float: left;">
<img src="#" alt="somepic" />
</div>
<article style="float: right;">
<h2>About me</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</article>
</section>
Yes, your markup structure is perfectly acceptable. An HTML5 section element can be used at your discretion to contain content related to a particular topic or activity. There are no specific rules about what elements it may include. You might use figure for your image wrapper as well. MDN
I recommend against using floats (which often lead to unpredictable or undesired behavior) and inline styles (which are just messy), though. Instead, set your elements to inline-block and give them explicit (percentage) widths using CSS classes in an embedded style tag or an external stylesheet.

I have a huge space between two lines of code how do i remove?

Between:
<h2>Menu</h2>
and
<h5>Hover to see more!</h5>
I have this huge gap, is there a way to remove it?
For more references this is my code before heading 2:
<div class="container">
<img src="Lato Font Test.png" alt="Avatar" class="image">
<div class="overlay">
<div class="text"><p>About Us // Origin</p><p>Sample Text</p><p>Sample Text</p><p>Sample Text</p></div>
</div>
</div>
<br></br>
And after heading 5:
<ul id="accordion">
<li>
<h2>MENU // SOUPS</h2>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.</p>
</div>
</li>
Picture Reference: http://i.imgur.com/Imc3DPb.png
Thanks in advance!
One of your elements has a default padding or margin. You can inspect your elements with your browsers dev tools to figure out which if not both is causing the issue. Adjust your paddings and margins using padding: x; and margin: x; x being the amount of pixels [ex. 5px] you want.

Bem naming conventions

im using the BEM naming convention within a small project and having some slight difficulty in deciding between element and modifier names.
I'm currently working on a hero/splash section of the website. see image below.
Heres my current code -
<div class="hero hero__project">
<div class="grid">
<h1 class="hero__project__title">Final Year Project</h1>
<div class="hero__project__meta">
<p>Published<span>23 Oct 2014</span></p>
<p>Applictions <span>Unity3d, Photoshop, 3ds max</span></p>
</div>
<p class="hero__project__summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in </p>
</div>
</div>
My question is - Do you understand what the piece of markup is doing? and is it in line with them BEM methodology. Thanks
As far as I understand BEM, I would say your naming does not make sense. Your Block (or module) would be your .hero. Your Elements would be your main components of your block (i.e. project-title, project-meta, etc). If you needed a modifier on your block for a different state, you could add one in addition to your block (e.g. class=".hero .hero--isHidden)
<div class="hero">
<div class="grid">
<h1 class="hero__project-title"></h1>
<div class="hero__project-meta"></div>
<p class="hero__project-summary"></p>
</div>
</div>
For more in-depth info checkout http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/
To answer your question regarding the other names, I guess I would modify my answer slightly. Again, only using the --project modifier to style the other elements if they are indeed different than a hero on another page.
<div class="hero hero--project">
<div class="grid">
<h1 class="hero__title"></h1>
<div class="hero__meta"></div>
<p class="hero__summary"></p>
</div>
</div>
I'm new to BEM and trying to wrap my head around it all. I read one of the rules for BEM was no nested selectors. So based off the 2nd answer, let's say we style the hero title to be black but style project hero titles to be red. Would the CSS look like this?
.hero__title { color: #000; }
.hero--project .hero__title { color: #cc0000; }

CSS - floating issue for a responsive design

Problem: http://i.snag.gy/TYvi4.jpg
Fiddle: http://jsfiddle.net/CadDC/7/
As you can see in the problem image above, I would like to position the image alongside the title but keeping the structure of the html for a responsive layout.
<div class="listingWrapper clearfix">
<div class="headlineText">FLOAT: RIGHT</div>
<div class="subText">FLOAT: RIGHT</div>
<div class="logo">FLOAT: LEFT (ALONGSIDE HEADLINE)</div>
<div class="introduction">FLOAT: RIGHT</div>
Look at this fiddle: http://jsfiddle.net/caprella/7kbVX/
I propose to add one more wrapper .heading for .headlineText and .subText. It will give us opportunity to move the whole header. But that .heading steel needs fixed width:(
Check the Js fiddle
http://jsfiddle.net/CadDC/9/
<div class="listingWrapper clearfix">
<div class="logo">
<img class="listingImage" src="http://media-cdn.tripadvisor.com/media/photo-s/02/d0/d7/ed/hotel-du-vin-york.jpg" />
</div>
<div class="headlineText"><h2>Hotel name</h2></div>
<div class="subText">Mars - 0.7 miles from Mars City Centre</div>
<div class="introduction">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nost
</div>
</div>
Cant you just:
.listingImage{
max-width: 190px;
float: left;
}
I think this is your perfect answer http://jsfiddle.net/CadDC/14/ .
If you want it to be responsive you must give width and all in %.