Mysql store HTML code - mysql

If I want to store HTML code to a database, is better to add one row with big HTML code or more rows with smaller HTML code?
In my app, I can edit the code in both ways, so don't really need more rows, but maybe is faster or more effective having more rows and smaller HTMl code.
What is your opinion? Thanks you.
HTML Code Example:
<div class="row">
<div class="col-sm-12">
<section data-type="component-text">
content
</section>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<section data-type="component-photo">
content
</section>
</div>
<div class="col-sm-6">
<section data-type="component-video">
content
</section>
</div>
</div>
The code is generated by a plugin. This is only an example created by me.

Answer: It depends on your querying needs.
Efficient querying is an extensive topic focused on design and algorithms.
It depends on the size, type and structure of the data you have.
If you just need to store all the HTML and get it back, you could simply store as much per block.
If you need specific lines of HTML per query then each block with the necessary content is a good idea!
I hope this helps.

Related

BEM Methodology proper HTML structure

I have a doubts about this HTML structure. Is it correct according to BEM approach?
<div class="boxWithBorder">
<div class="header">
<h2 class="boxWithBorder__element"></h2>
</div>
</div>
To my mind it should look like that
<div class="boxWithBorder">
<div class="header">
<h2 class="header__element"></h2>
</div>
</div>
What keeps elements encapsulated.
Generally we do components and structures, that means structures are compositions of components. It will require nesting so that part is ok. As far as your first approach that is not ok by our standards and not used. block1 should not live inside block2 but block2 has to live inside block1 as it's a nested component. Makes sense? BTW BEM is perfectly fine to use and a lot of frontend devs do it, heavyweights as well, check out csswizardry.com for instance, he got some great articles about BEM
Also I would suggest the following using BEM (or any html/css for that matter) is that skip the camleCase and use "-" instead
<div class="box-with-border">
<div class="header">
<h2 class="header__element"></h2>
</div>
</div>
<div class="hero hero--red-with-border">
<h1 class="hero__title>Title...</h1>
<p class="hero__body-text">Text...</p>
</div>

Where to put semantically meaningfull blocks in twitter bootstrap skeleton?

this is my first question, so please, do not judge strictly. The essence is in follows: I imagine block structure of document as a printing press - but very remotely, of course - because press already hase content and semantic, while div's structure of document - only skeleton for it, and both mentioned subjects must be added. An object of concern to me is where I should put this semantic in document skeleton, formed with twitter bootstrap and defining structure - for example:
<div class="container">
<div class="row">
<div class="col-xs-12">
Content, which must be wrapped in some semantically meaningfull element - like, for example - article-preview class
</div>
</div>
</div>
I see two different ways, but dont know, what way is better practice in marking down html documents:
1) Adding semantic class to element, which already have class that forming my document structure - col-xs-12 - or press in my analogy.
<div class="container">
<div class="row">
<div class="col-xs-12 article-preview">
'Content, which must be wrapped in some semantically meaningfull element like, for example - article-preview class'
</div>
</div>
</div>
2) Or adding brand new semanit block under structuring block and putting my content here:
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="article-preview">
Content, which must be wrapped in some semantically meaningfull element - like, for example - article-preview class
</div>
</div>
</div>
</div>
I apologize if the question seems a little stupid to you, but I thinking about it for really long time and from now on can not do anything until it is resolved.
Thank you!
I will prefer the second way. Because bootstrap cols have their own styles and structure, so if you have additional styles or codes try to do like second way.
I think we should keep the bootstrap structure.
Go with the first approach because I feel the second approach will make your code long unnecessarily.
With the first approach as well you can add your custom styles. just add your stylesheet after the bootstrap css.

about psd to html, only images?

Why isn't it possible to convert a layered image (such as in Photoshop) to a good web page with maintainable code?
<div id="2copy3"><img src="images/2copy3.png"></div>
<div id="Layer24"><img src="images/Layer24.png"></div>
<div id="Lines"><img src="images/Lines.png"></div>
<div id="Shape1"><img src="images/Shape1.png"></div>
<div id="Tab"><img src="images/Tab.png"></div>
<div id="Home"><img src="images/Home.png"></div>
<div id="LocationSouthAfrica"><img src="images/LocationSouthAfrica.png"></div>
<div id="CrewDragna"><img src="images/CrewDragna.png"></div>
<div id="Health100"><img src="images/Health100.png"></div>
<div id="Points44080"><img src="images/Points44080.png"></div>
<div id="Bullets28883"><img src="images/Bullets28883.png"></div>
<div id="TableDesign"><img src="images/TableDesign.png"></div>
Converting a visual representation to a fully functioning web page that is well thought out for many devices is something that requires a human. There is no algorithm (thus far, maybe in science fiction) that can make the appropriate decisions for interpreting a design and building a site out of it.
It's not just a conversion. There is an art to this. Unless of course you want a page that is just images...

What ways are there make HTML modular?

HTML often has repeating and independent structures that are modular on a theoretical level, such as multiple portfolio-items:
<div class="protfolio-item">
<div class="image">
<a ...><img /></a>
...
</div>
<div class="portfolio-content">
<h2>...</h2>
<p>...</p>
</div>
</div>
Even writing them out feels stupid. Now I want to make a change, like having an icon superposed on every picture. What ways are there to achieve more modular code that's easier to change? Are there any non-PHP "native" ways to do so?
Non-PHP, native? The first thing I can think of is Server Side Includes - not very powerful but you can divide your document into pieces making it modular. The main disadvantage is lack of loops.

Is it a bad practice to use divs for styling purposes?

I've seen lately a lot of discussions about this new concept called oocss and I was wondering if it is a bad practice to wrap your main tags in divs only for styling/page layout purposes.
I'm asking this because I see some frameworks like Twitter Bootstrap use such a method.
What are the implications of such a markup from a semantic and accessibility point of view?
For example:
<div class="container">
<div class="row">
<div class="span4">
<nav class="nav">...</nav>
</div>
<div class="span8">
...
</div>
</div>
</div>
instead of
<div class="menu">
<nav class="nav">...</nav>
...
</div>
No, it's fine. HTML is a "mark-up language", and mark-up involves styling. Besides, everyone does it. Many of the fluid multi-column layouts rest precisely on this approach.
Using unnecessary divs is not a good idea... if the HTML codes in the second box is enough to do everything that you want or need to do then don't use extra divs... secondly, HTML codes in the second box is much clear and shorter then the codes in the first box... if you keep your codes clean, short and formatted, it will help you a lot when you want or need to update your code in future...